public class WordExporter extends AbstractAppExporter
限定符和类型 | 字段和说明 |
---|---|
protected static int |
EXPORT_RESOLUTION |
构造器和说明 |
---|
WordExporter()
构造函数
|
限定符和类型 | 方法和说明 |
---|---|
protected int |
addToTable(ClippedPageProvider clipped,
com.fr.third.com.lowagie.text.Table table)
将当前页内容添加到Table中去.
|
protected int |
addToTable(ClippedPageProvider clipped,
com.fr.third.com.lowagie.text.Table table,
int last_row,
int temp_page_row)
将当前页内容添加到Table中去.
|
protected com.fr.third.com.lowagie.text.Cell |
createCellFromCellElement(CellElement cellElement,
DynamicUnitList columnWidthList,
DynamicUnitList rowHeightList)
将paintElement转换为Cell
|
protected com.fr.third.com.lowagie.text.Cell |
createDefaultCell(java.awt.Color bgColor)
创建默认的rtf cell
|
protected void |
dealWithHeaderFooter(ReportPageProvider reportPage,
com.fr.third.com.lowagie.text.Document document)
处理页眉页脚, 如果是纯文本则直接展现文字, 导出后可编辑.
|
void |
export(java.io.OutputStream out,
PageSetProvider pageSet)
导出报表到rtf, 导出Word
|
void |
export(java.io.OutputStream out,
ResultWorkBook book)
导出报表到rtf
|
void |
export(java.io.OutputStream out,
ResultWorkBook workBook,
PageSetCreator pageSet,
ReportRepositoryDeal repo,
int[] sheets)
导出
|
void |
exportPage(java.io.OutputStream out,
PageSetProvider pageSet,
int[] pageIds)
开个方法给客户用 可以把指定的页导出到一个Word上
一页导出一个word组成个压缩包输出的例子:
WorkBook workbook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCommonOperator(), "1.cpt");
PageRWorkBook book = (PageRWorkBook) workbook.execute(new HashMap(), ActorFactory.getActor("page"));
PageSetChainProvider chain = book.generateReportPageSet(ReportUtils.getPaperSettingListFromWorkBook(workbook));
PageSetProvider pageSet = chain.traverse4Export();
OutputStream os = new FileOutputStream(new File("c:/aa.zip"));
ZipOutputStream zo = new ZipOutputStream(os);
for (int i = 0; i < pageSet.size(); i++) {
zo.putNextEntry(new ZipEntry(i + ".doc"));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new WordExporter().exportPage(bos, pageSet, new int[]{i});
zo.write(bos.toByteArray());
}
zo.flush();
zo.close();
os.flush();
os.close();
当然也可以一页一个word文档
|
protected void |
initPaperSetting(ReportPageProvider reportPage,
com.fr.third.com.lowagie.text.Document document,
int index)
初始化纸张大小, 页眉页脚, 边距设置
|
protected void |
initTable(com.fr.third.com.lowagie.text.Table table,
ReportPageProvider reportPage,
int cols,
ClippedPageProvider clipped,
com.fr.third.com.lowagie.text.Document document)
初始化word中的Table
|
export, setVersion
protected static final int EXPORT_RESOLUTION
public void export(java.io.OutputStream out, ResultWorkBook workBook, PageSetCreator pageSet, ReportRepositoryDeal repo, int[] sheets) throws java.lang.Exception
AppExporter
export
在接口中 AppExporter
export
在类中 AbstractAppExporter
out
- 输出流workBook
- 结果报表pageSet
- 分页集合repo
- 浏览器相关sheets
- sheet索引集合java.lang.Exception
- 导出失败则抛出此异常public void export(java.io.OutputStream out, ResultWorkBook book) throws java.lang.Exception
out
- 文件输出流book
- 待导出的报表java.lang.Exception
- 导出失败则抛出此异常public void export(java.io.OutputStream out, PageSetProvider pageSet) throws java.lang.Exception
export
在接口中 AppExporter
export
在类中 AbstractAppExporter
out
- 文件输出流pageSet
- 待导出的报表分页集合java.lang.Exception
- 导出失败则抛出此异常public void exportPage(java.io.OutputStream out, PageSetProvider pageSet, int[] pageIds) throws java.lang.Exception
一页导出一个word组成个压缩包输出的例子:
WorkBook workbook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCommonOperator(), "1.cpt"); PageRWorkBook book = (PageRWorkBook) workbook.execute(new HashMap(), ActorFactory.getActor("page")); PageSetChainProvider chain = book.generateReportPageSet(ReportUtils.getPaperSettingListFromWorkBook(workbook)); PageSetProvider pageSet = chain.traverse4Export(); OutputStream os = new FileOutputStream(new File("c:/aa.zip")); ZipOutputStream zo = new ZipOutputStream(os); for (int i = 0; i < pageSet.size(); i++) { zo.putNextEntry(new ZipEntry(i + ".doc")); ByteArrayOutputStream bos = new ByteArrayOutputStream(); new WordExporter().exportPage(bos, pageSet, new int[]{i}); zo.write(bos.toByteArray()); } zo.flush(); zo.close(); os.flush(); os.close();
当然也可以一页一个word文档
out
- 文件输出流pageSet
- 报表分页集合pageIds
- 需要导出的页码数组java.lang.Exception
protected int addToTable(ClippedPageProvider clipped, com.fr.third.com.lowagie.text.Table table)
clipped
- 待添加的报表页table
- word中的tableprotected int addToTable(ClippedPageProvider clipped, com.fr.third.com.lowagie.text.Table table, int last_row, int temp_page_row)
clipped
- 待添加的报表页table
- word中的tablelast_row
- 添加完一页内容后的报表结尾行temp_page_row
- 已添加到word中的总行数protected void initPaperSetting(ReportPageProvider reportPage, com.fr.third.com.lowagie.text.Document document, int index)
reportPage
- 当前页报表对象document
- 待导出的rtf documentindex
- 当前页码protected void initTable(com.fr.third.com.lowagie.text.Table table, ReportPageProvider reportPage, int cols, ClippedPageProvider clipped, com.fr.third.com.lowagie.text.Document document)
table
- 待初始化的TablereportPage
- 当前报表对象cols
- 总列数clipped
- 当前分页报表document
- 待导出的rtf documentprotected void dealWithHeaderFooter(ReportPageProvider reportPage, com.fr.third.com.lowagie.text.Document document)
reportPage
- 当前报表对象document
- 待导出的rtf documentprotected com.fr.third.com.lowagie.text.Cell createDefaultCell(java.awt.Color bgColor) throws java.lang.Exception
bgColor
- 默认报表背景java.lang.Exception
protected com.fr.third.com.lowagie.text.Cell createCellFromCellElement(CellElement cellElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList) throws java.lang.Exception
cellElement
- 当前报表格子columnWidthList
- 报表列宽集合rowHeightList
- 报表行高集合java.lang.Exception