public class ExcelReportImporter
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
ExcelReportImporter.ExcelPicture |
限定符和类型 | 字段和说明 |
---|---|
static int |
DEFAULT_EXCEL_CELL_WIDTH |
static int |
FULL_COLOR |
static int |
KILO |
构造器和说明 |
---|
ExcelReportImporter() |
限定符和类型 | 方法和说明 |
---|---|
static Style |
applyAlignStyle(short horizonAlign,
short verticalAlign,
Style style)
设置对齐样式
|
protected int |
computeInsertCount(int start,
int end,
int stepLen,
int cur_size)
计算插入的行列跨度
|
static Style |
format(java.lang.String formatString,
Style style)
格式转化
|
WorkBook |
generateWorkBookByStream(java.io.InputStream in)
根据excel对应的流数据构建一个WorkBook
|
WorkBook |
generateWorkBookByStream(java.io.InputStream in,
java.util.Map<java.lang.String,java.lang.Object> paraMap)
根据excel对应的流数据构建一个WorkBook
读入Excel2003文件转化成WorkBook例子:
InputStream in = new FileInputStream(new File("c:/a.xls"));
TemplateWorkBook template = new ExcelReportImporter().generateWorkBookByStream(in, new HashMap());
|
static java.util.List<ExcelReportImporter.ExcelPicture> |
getAllPictures(com.fr.third.org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
获取Excel中的图片并包装相关信息
|
static int |
getBorderStyle(short hssfBorderStyle)
边框
|
protected int |
getCellExpandSize(WriteECReport curReport,
int col,
int row,
boolean isTopToBottom)
获取报表单元格扩展行数
|
java.util.Map<java.lang.String,java.lang.String> |
getExcelTitleConfig() |
protected int |
getMinMatchCount(java.util.List<java.lang.String> write_title_list,
java.lang.String sheetName) |
protected java.lang.String |
getType() |
void |
importExcel2Book(ReportSessionIDInfor reportSessionIDInfor,
FineBook source,
TemplateWorkBook template,
java.util.Map<java.lang.String,java.lang.Object> map4Execute,
boolean checkWidget) |
void |
importExcel2Book(WriteWorkBook book,
FineBook source,
TemplateWorkBook template,
java.util.Map<java.lang.String,java.lang.Object> map4Execute)
step 1:找到可能会有不定行扩展的扩展块,最多一个
how :直接找是数据列的格子。
|
void |
importExcel2Book(WriteWorkBook book,
FineBook source,
TemplateWorkBook template,
java.util.Map<java.lang.String,java.lang.Object> map4Execute,
boolean checkWidget)
把引入的excel生成的模板整合到原始的填报页面中
Excel导入的例子:
TableDataSource source = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCommonOperator(), "1.cpt");
TemplateWorkBook template = new WorkBook(); //excel文件数据生成的模板
ResultWorkBook book = ((WorkBook) source).execute(new HashMap(), new WriteActor());
ExcelReportImporter.importExcel2Book((WriteWorkBook)book, source, template, new HashMap());
|
protected void |
insertData(WriteECReport curReport,
CellElement topce,
boolean vertical,
int startRC,
int rect_len,
int insertCount)
插入数据
|
protected boolean |
isByLocation(ECReport excelReport,
WriteECReport curReport)
是否按照位置匹配, 要求行列数目完全相等.
|
protected boolean |
needInsert(int num,
int cur_size) |
protected void |
setDataAboveUncertain(WriteECReport curReport,
ECReport excelReport,
boolean vertical,
boolean checkWidget,
int startRC,
java.util.List<WriteCellElement> cellNeedToPresentList,
java.util.List<java.util.List<CellElement>> line_v_list,
CellElement topce,
java.lang.String sheetName)
设置不定行上方的格子
|
protected void |
setDataAfterAppend(WriteECReport curReport,
ECReport excelReport,
boolean vertical,
boolean checkWidget,
int startRC,
java.util.List<WriteCellElement> cellNeedToPresentList,
java.util.List<java.util.List<CellElement>> line_v_list,
java.util.List<CellElement> res_wg_rect_list,
CellElement topce,
int sheetIndex,
int expand_size,
java.util.List<CellElement> uc_exp_rect_list)
赋值给插入行后的格子
|
void |
setExcelTitleConfig(java.util.Map<java.lang.String,java.lang.String> excelTitleConfig) |
protected static void |
setValue4ExcelImport(WriteCellElement cell,
java.lang.Object value,
java.util.List<WriteCellElement> cellNeedToPresentList,
Report report)
设置单元格值
|
public static int DEFAULT_EXCEL_CELL_WIDTH
public static int KILO
public static int FULL_COLOR
public java.util.Map<java.lang.String,java.lang.String> getExcelTitleConfig()
public void setExcelTitleConfig(java.util.Map<java.lang.String,java.lang.String> excelTitleConfig)
public WorkBook generateWorkBookByStream(java.io.InputStream in) throws java.lang.Exception
in
- 输入流java.lang.Exception
public WorkBook generateWorkBookByStream(java.io.InputStream in, java.util.Map<java.lang.String,java.lang.Object> paraMap) throws java.lang.Exception
读入Excel2003文件转化成WorkBook例子:
InputStream in = new FileInputStream(new File("c:/a.xls")); TemplateWorkBook template = new ExcelReportImporter().generateWorkBookByStream(in, new HashMap());
in
- 输入流paraMap
- 参数mapjava.lang.Exception
public static Style applyAlignStyle(short horizonAlign, short verticalAlign, Style style)
horizonAlign
- 横向对齐方式verticalAlign
- 纵向对齐方式style
- 样式public static Style format(java.lang.String formatString, Style style)
formatString
- excel格式style
- 报表格子样式public static int getBorderStyle(short hssfBorderStyle)
hssfBorderStyle
- Excel边框样式public void importExcel2Book(WriteWorkBook book, FineBook source, TemplateWorkBook template, java.util.Map<java.lang.String,java.lang.Object> map4Execute) throws WriteExcelImportException, java.lang.Exception
book
- 原始ctp模板source
- 数据template
- excel数据生成的模板map4Execute
- 参数java.lang.Exception
WriteExcelImportException
public void importExcel2Book(ReportSessionIDInfor reportSessionIDInfor, FineBook source, TemplateWorkBook template, java.util.Map<java.lang.String,java.lang.Object> map4Execute, boolean checkWidget) throws WriteExcelImportException, java.lang.Exception
WriteExcelImportException
java.lang.Exception
public void importExcel2Book(WriteWorkBook book, FineBook source, TemplateWorkBook template, java.util.Map<java.lang.String,java.lang.Object> map4Execute, boolean checkWidget) throws java.lang.Exception
Excel导入的例子:
TableDataSource source = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCommonOperator(), "1.cpt"); TemplateWorkBook template = new WorkBook(); //excel文件数据生成的模板 ResultWorkBook book = ((WorkBook) source).execute(new HashMap(), new WriteActor()); ExcelReportImporter.importExcel2Book((WriteWorkBook)book, source, template, new HashMap());
book
- 原始ctp模板source
- 数据template
- excel数据生成的模板map4Execute
- 参数checkWidget
- 是否检测widgetjava.lang.Exception
protected boolean isByLocation(ECReport excelReport, WriteECReport curReport)
excelReport
- Excel报表curReport
- 填报报表protected int getCellExpandSize(WriteECReport curReport, int col, int row, boolean isTopToBottom)
curReport
- row
- col
- isTopToBottom
- protected boolean needInsert(int num, int cur_size)
protected java.lang.String getType()
protected void insertData(WriteECReport curReport, CellElement topce, boolean vertical, int startRC, int rect_len, int insertCount) throws WriteException
curReport
- 当前报表topce
- 顶层父格vertical
- 是否纵向startRC
- 不定行起始行列rect_len
- 扩展块跨度insertCount
- 插入的行数WriteException
protected int computeInsertCount(int start, int end, int stepLen, int cur_size)
start
- 起始点end
- 结束点stepLen
- 步长protected static void setValue4ExcelImport(WriteCellElement cell, java.lang.Object value, java.util.List<WriteCellElement> cellNeedToPresentList, Report report)
cell
- 单元格value
- 当前值cellNeedToPresentList
- 形态列表protected void setDataAboveUncertain(WriteECReport curReport, ECReport excelReport, boolean vertical, boolean checkWidget, int startRC, java.util.List<WriteCellElement> cellNeedToPresentList, java.util.List<java.util.List<CellElement>> line_v_list, CellElement topce, java.lang.String sheetName)
curReport
- 当前报表excelReport
- Excel报表vertical
- 是否纵向checkWidget
- 检测控件startRC
- 起始行列cellNeedToPresentList
- 形态列表sheetName
- 当前sheet名称(excel中的)protected void setDataAfterAppend(WriteECReport curReport, ECReport excelReport, boolean vertical, boolean checkWidget, int startRC, java.util.List<WriteCellElement> cellNeedToPresentList, java.util.List<java.util.List<CellElement>> line_v_list, java.util.List<CellElement> res_wg_rect_list, CellElement topce, int sheetIndex, int expand_size, java.util.List<CellElement> uc_exp_rect_list)
curReport
- 当前报表excelReport
- Excel报表vertical
- 是否纵向checkWidget
- 是否检测控件startRC
- 起始行列cellNeedToPresentList
- 形态列表line_v_list
- 导入的格子列表res_wg_rect_list
- 控件列表sheetIndex
- sheet下标expand_size
- 插入前扩展行数uc_exp_rect_list
- 不定行起始单元格列表protected int getMinMatchCount(java.util.List<java.lang.String> write_title_list, java.lang.String sheetName)
public static java.util.List<ExcelReportImporter.ExcelPicture> getAllPictures(com.fr.third.org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
workbook
- 报表