public abstract class AbstractExcelExporter<T> extends AbstractAppExporter<T>
限定符和类型 | 类和说明 |
---|---|
static interface |
AbstractExcelExporter.FontAdapter |
static class |
AbstractExcelExporter.JavaFontAdapter |
protected static class |
AbstractExcelExporter.TextFontAdapter |
限定符和类型 | 字段和说明 |
---|---|
static short |
A3_PAGE_SIZE |
static short |
A6_PAGE_SIZE |
static short |
B4_PAGE_SIZE |
static short |
B5_PAGE_SIZE |
protected IntList |
colorList |
protected java.util.Map[] |
columnRowPostileMaps |
static short |
DEFAULT_COL_WIDTH |
protected static short |
DEFAULT_FONT |
static int |
DEFAULT_SCALE |
static int |
EIGHTH |
protected ExcelHiddenCellsTool |
ex_tool |
static int |
EXCEL_EXPORT_RESOLUTION |
protected static double |
FONT_SCALE |
static java.lang.String |
FORMULA_ERROR |
static double |
HANDRED |
static int |
HEIGHT_LIMIT |
protected java.util.HashMap |
hssfCellStyleHash |
protected java.util.HashMap |
hssfFontHash |
static short |
LEDGER_PAGE_SIZE |
protected static int |
MAX_PROPER_FONT |
static short |
NOTE_PAGE_SIZE |
protected java.util.List |
paperSettingList |
static int |
PICTURE_TYPE_PNG |
protected static int |
ROTATION_DOWN |
protected static int |
ROTATION_UPPER |
protected int[] |
sheets2Export |
protected int |
totalBreak |
构造器和说明 |
---|
AbstractExcelExporter() |
限定符和类型 | 方法和说明 |
---|---|
protected Style |
adjustProperFontSize(Style style)
调整下当前格子导出的字体大小
|
protected void |
applyReportHFFooter(ReportHFProvider reportHF,
POIHeaderFooterAction footer)
设置页脚
|
protected void |
applyReportHFHeader(ReportHFProvider reportHF,
POIHeaderFooterAction header)
设置页眉
|
protected boolean |
checkInvalidFormula(java.lang.String formulaText)
用FRParser来判断公式是否合法
|
protected java.lang.Object |
checkNumberFormat(java.text.Format cFormat,
java.lang.Object value) |
protected java.lang.Object |
checkValueVertical(java.lang.Object value,
Style style,
int width,
int height) |
protected void |
createComplexFont4FR(FRFont frFont,
POIFontAction font)
复杂点的字体设置, java原生的不带, 字体上下标, 下划线等
|
protected abstract POIFontAction |
createFont(POIWorkbookAction wbWrapper,
java.awt.Font font) |
protected POIFontAction |
createSimpleFont(POIWorkbookAction wb,
AbstractExcelExporter.FontAdapter font,
POIFontAction fontWrapper,
java.lang.String cellFontName)
获取当前字体的样式, 并加以缓存
|
protected void |
dealWithAlignAndMargin(POISheetAction sheet,
ReportSettingsProvider reportSettings,
Margin margin)
设置是否垂直水平居中, 以及边距
|
protected void |
dealWithBufferImage(java.lang.Object value,
POIClientAnchorAction clientAnchor,
POIPatriarchAction patriarch,
Style style,
int width,
int height,
java.awt.image.BufferedImage buffImg,
POIWorkbookAction wb)
将BufferImage转化成excel中的悬浮元素
|
protected void |
dealWithFormula(POICellAction poiCell,
java.lang.String contentFormula)
导出保留公式
|
protected int[] |
dealWithHiddenCR(int start,
int span,
IntList hiddenList) |
protected void |
dealWithPrintSetUp(POIPrintSetupAction printSetup,
PaperSize paperSize,
int orientation,
ReportSettingsProvider reportSettings)
导出当前报表的打印设置到excel, 包括纸张, 横纵向, 页眉页脚距离
|
protected java.lang.String |
dealWithSumFormula(java.lang.String content,
java.lang.Object value,
BaseFormula formula,
boolean needReExFormula) |
protected java.lang.Object |
evalCellValue(CellElement cellElement,
boolean exHiddenRow,
boolean exHiddenColumn,
java.util.List hssfCellList,
POICellAction hssfCell,
Calculator cal,
Style style,
java.util.List hssfCellFormulaList,
CellGUIAttr cellGUIAttr,
DynamicUnitList rowHeightList,
DynamicUnitList columnWidthList,
int column,
int row,
int columnSpan,
int rowSpan,
POIWorkbookAction wb) |
protected java.lang.Object |
evalFormulaValue(java.lang.Object value,
boolean exHiddenRow,
boolean exHiddenColumn,
java.util.List cellList,
POICellAction cell,
Calculator cal,
java.util.List cellFormulaContentList)
重新计算存在公式的单元格的值
|
protected java.lang.Object |
evalHtmlContent(POIWorkbookAction wb,
java.lang.Object value,
Style style,
int width,
int height) |
protected void |
executeCellStyle(POIWorkbookAction wb,
POICellStyleAction hssfCellStyle,
Style style)
将报表中的单元格样式设置到excel单元格中
|
abstract void |
export(java.io.OutputStream out,
ResultWorkBook workbook)
导出Workbook
|
protected void |
exportBook(ResultWorkBook book,
POIWorkbookAction workbookWrapper,
java.util.List cellList,
java.util.List<java.lang.String> cellFormulaList,
java.util.List<Report> reportList,
boolean reUse)
将报表导出成excel
|
protected void |
exportBook(ResultWorkBook book,
POIWorkbookAction workbookWrapper,
java.util.List cellList,
java.util.List<java.lang.String> cellFormulaList,
java.util.List<Report> reportList,
boolean reUse,
int[] sheets)
将报表导出成excel
|
protected abstract int |
getFloatLeftMax(double columnWidth) |
protected abstract int |
getFloatTopMax(double rowHeight) |
protected abstract short |
getFormat(POIWorkbookAction wb,
java.lang.String pattern) |
protected short |
getMapBorder(int border)
根据报表设置的边框线返回Excel对应的线型
|
protected java.lang.String |
getPassword(ResultWorkBook book)
获取报表中设置的Excel导出保护工作表密码
|
protected abstract short |
getRotation(Style style) |
protected POIRichStringAction |
html2HSSFRichTextString(POIWorkbookAction wb,
java.lang.String html,
Style style) |
protected abstract POIRichStringAction |
initRichString(java.lang.String content) |
protected abstract void |
innerExportReports(ResultECReport innerReport,
ResultWorkBook book,
POIWorkbookAction workbook,
java.util.List cellList,
java.util.List<java.lang.String> cellFormulaList,
java.util.List<Report> reportList,
int index) |
protected boolean |
isShowAsImage(int textStyle,
CellGUIAttr cellGUIAttr) |
protected int |
loadPicture(java.awt.image.BufferedImage bufferedImage,
POIWorkbookAction wb) |
protected POIPictureLocation |
locateFloatElementInExcel(FloatElement floatElement,
DynamicUnitList rowHeightList,
DynamicUnitList columnWidthList,
ElementCase report,
java.lang.Object value)
定位excel中悬浮元素的位置
|
protected java.lang.String |
replaceNewLineChar(java.lang.String allString)
peter:替换成newline
|
protected void |
setAttr4ECReportSIL(Calculator cal,
IntList hiddenRowList,
IntList hiddenColList,
ElementCase report) |
protected void |
setColumnRowBreak(CellElement cellElement,
POISheetAction sheet,
int column,
int row,
int lastColumn,
int lastRow)
设置Excel中的行列分页点
|
protected void |
setDefaultFont(POIWorkbookAction hssfWorkbook)
设置导出默认字体
|
void |
setPostilMap(java.util.Map[] columnRowPostileMaps)
设置标识错误的单元格
|
protected void |
setSheetName(POIWorkbookAction wb,
java.lang.String name4Sheet)
设置Excelsheet的名字, 同时避免在Workbook中出现重命名现象
限定长度为31个字符
|
void |
setSheets2Export(int[] sheets) |
export, export, export, setVersion
protected static final short DEFAULT_FONT
public static final short DEFAULT_COL_WIDTH
public static final int PICTURE_TYPE_PNG
public static final int EXCEL_EXPORT_RESOLUTION
public static final java.lang.String FORMULA_ERROR
protected static final int MAX_PROPER_FONT
protected static final double FONT_SCALE
public static final short A3_PAGE_SIZE
public static final short A6_PAGE_SIZE
public static final short B4_PAGE_SIZE
public static final short B5_PAGE_SIZE
public static final short NOTE_PAGE_SIZE
public static final short LEDGER_PAGE_SIZE
protected static final int ROTATION_UPPER
protected static final int ROTATION_DOWN
public static final double HANDRED
public static final int DEFAULT_SCALE
public static final int HEIGHT_LIMIT
public static final int EIGHTH
protected java.util.List paperSettingList
protected java.util.HashMap hssfFontHash
protected java.util.HashMap hssfCellStyleHash
protected IntList colorList
protected java.util.Map[] columnRowPostileMaps
protected ExcelHiddenCellsTool ex_tool
protected int totalBreak
protected int[] sheets2Export
public abstract void export(java.io.OutputStream out, ResultWorkBook workbook) throws java.lang.Exception
out
- 输出流workbook
- 结果报表java.lang.Exception
protected abstract short getFormat(POIWorkbookAction wb, java.lang.String pattern)
protected abstract POIFontAction createFont(POIWorkbookAction wbWrapper, java.awt.Font font)
protected abstract short getRotation(Style style)
protected abstract int getFloatLeftMax(double columnWidth)
protected abstract int getFloatTopMax(double rowHeight)
public void setSheets2Export(int[] sheets)
protected java.lang.Object checkValueVertical(java.lang.Object value, Style style, int width, int height)
protected boolean isShowAsImage(int textStyle, CellGUIAttr cellGUIAttr)
protected int[] dealWithHiddenCR(int start, int span, IntList hiddenList)
protected java.lang.String dealWithSumFormula(java.lang.String content, java.lang.Object value, BaseFormula formula, boolean needReExFormula)
protected java.lang.Object checkNumberFormat(java.text.Format cFormat, java.lang.Object value)
protected void setAttr4ECReportSIL(Calculator cal, IntList hiddenRowList, IntList hiddenColList, ElementCase report)
public void setPostilMap(java.util.Map[] columnRowPostileMaps)
columnRowPostileMaps
- 标识错误的单元格组成的mapprotected void dealWithFormula(POICellAction poiCell, java.lang.String contentFormula)
poiCell
- 当前处理的poi单元格contentFormula
- 当前格子设置的公式内容protected java.lang.String getPassword(ResultWorkBook book)
book
- 当前导出的结果报表protected void setSheetName(POIWorkbookAction wb, java.lang.String name4Sheet)
wb
- 当前的Excel Bookname4Sheet
- 指定的sheet名protected void dealWithPrintSetUp(POIPrintSetupAction printSetup, PaperSize paperSize, int orientation, ReportSettingsProvider reportSettings)
printSetup
- excel中的打印设置paperSize
- 报表中的纸张设置orientation
- 横纵向显示reportSettings
- 报表页面设置protected void dealWithAlignAndMargin(POISheetAction sheet, ReportSettingsProvider reportSettings, Margin margin)
sheet
- 导出的poisheetreportSettings
- 报表页面设置margin
- 边距protected void dealWithBufferImage(java.lang.Object value, POIClientAnchorAction clientAnchor, POIPatriarchAction patriarch, Style style, int width, int height, java.awt.image.BufferedImage buffImg, POIWorkbookAction wb)
value
- 当前悬浮元素clientAnchor
- excel中定位元素patriarch
- excel中的悬浮元素style
- 悬浮元素样式width
- 悬浮元素宽度height
- 悬浮元素高度buffImg
- 待转化的BufferImagewb
- 当前excel工作表protected POIFontAction createSimpleFont(POIWorkbookAction wb, AbstractExcelExporter.FontAdapter font, POIFontAction fontWrapper, java.lang.String cellFontName)
wb
- 导出的excel workbookfont
- 字体适配器fontWrapper
- excel中的字体protected void createComplexFont4FR(FRFont frFont, POIFontAction font)
frFont
- 报表里的fontfont
- excel中的fontprotected void executeCellStyle(POIWorkbookAction wb, POICellStyleAction hssfCellStyle, Style style)
wb
- excel报表hssfCellStyle
- excel格子样式style
- 报表格子样式protected short getMapBorder(int border)
border
- 报表边框线线型protected int loadPicture(java.awt.image.BufferedImage bufferedImage, POIWorkbookAction wb) throws java.io.IOException
java.io.IOException
protected void applyReportHFHeader(ReportHFProvider reportHF, POIHeaderFooterAction header)
reportHF
- 报表的页眉页脚header
- 当前excel sheet的页眉protected void applyReportHFFooter(ReportHFProvider reportHF, POIHeaderFooterAction footer)
reportHF
- 报表的页眉页脚footer
- 当前excel sheet的页脚protected boolean checkInvalidFormula(java.lang.String formulaText)
formulaText
- 公式内容protected void setDefaultFont(POIWorkbookAction hssfWorkbook)
protected void exportBook(ResultWorkBook book, POIWorkbookAction workbookWrapper, java.util.List cellList, java.util.List<java.lang.String> cellFormulaList, java.util.List<Report> reportList, boolean reUse) throws java.lang.Exception
book
- 结果报表workbookWrapper
- 导出的excel表cellList
- 单元格列表cellFormulaList
- 单元格保留公式列表reportList
- 报表集合reUse
- 是否可以重用java.lang.Exception
protected void exportBook(ResultWorkBook book, POIWorkbookAction workbookWrapper, java.util.List cellList, java.util.List<java.lang.String> cellFormulaList, java.util.List<Report> reportList, boolean reUse, int[] sheets) throws java.lang.Exception
book
- 结果报表workbookWrapper
- 导出的excel表cellList
- 单元格列表cellFormulaList
- 单元格保留公式列表reportList
- 报表集合reUse
- 是否可以重用sheets
- 导出的sheet序号java.lang.Exception
protected Style adjustProperFontSize(Style style)
style
- 当前格子样式protected abstract void innerExportReports(ResultECReport innerReport, ResultWorkBook book, POIWorkbookAction workbook, java.util.List cellList, java.util.List<java.lang.String> cellFormulaList, java.util.List<Report> reportList, int index)
protected java.lang.String replaceNewLineChar(java.lang.String allString)
protected POIPictureLocation locateFloatElementInExcel(FloatElement floatElement, DynamicUnitList rowHeightList, DynamicUnitList columnWidthList, ElementCase report, java.lang.Object value)
floatElement
- 报表中的悬浮元素rowHeightList
- 报表行高集合columnWidthList
- 报表列宽集合report
- 当前报表value
- 当前格子的值protected void setColumnRowBreak(CellElement cellElement, POISheetAction sheet, int column, int row, int lastColumn, int lastRow)
cellElement
- 当前单元格sheet
- 当前报表sheetcolumn
- 当前列row
- 当前行lastColumn
- 上一个单元格处理的列lastRow
- 上一个单元格处理的行protected POIRichStringAction html2HSSFRichTextString(POIWorkbookAction wb, java.lang.String html, Style style) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object evalHtmlContent(POIWorkbookAction wb, java.lang.Object value, Style style, int width, int height)
protected abstract POIRichStringAction initRichString(java.lang.String content)
protected java.lang.Object evalFormulaValue(java.lang.Object value, boolean exHiddenRow, boolean exHiddenColumn, java.util.List cellList, POICellAction cell, Calculator cal, java.util.List cellFormulaContentList)
value
- 公式exHiddenRow
- 是否隐藏行exHiddenColumn
- 是否隐藏列cellList
- 保存含有公式的单元格列表cell
- 单元格cal
- calcellFormulaContentList
- 单元格公式重新依据单元格导出的位置计算过后的公式内容protected java.lang.Object evalCellValue(CellElement cellElement, boolean exHiddenRow, boolean exHiddenColumn, java.util.List hssfCellList, POICellAction hssfCell, Calculator cal, Style style, java.util.List hssfCellFormulaList, CellGUIAttr cellGUIAttr, DynamicUnitList rowHeightList, DynamicUnitList columnWidthList, int column, int row, int columnSpan, int rowSpan, POIWorkbookAction wb)