Package org.apache.poi.hssf.converter
Class ExcelToFoConverter
- java.lang.Object
-
- org.apache.poi.hssf.converter.AbstractExcelConverter
-
- org.apache.poi.hssf.converter.ExcelToFoConverter
-
@Beta public class ExcelToFoConverter extends AbstractExcelConverter
Converts xls files (97-2007) to XSL FO.
-
-
Field Summary
-
Fields inherited from class org.apache.poi.hssf.converter.AbstractExcelConverter
_formatter
-
-
Constructor Summary
Constructors Constructor Description ExcelToFoConverter(FoDocumentFacade foDocumentFacade)
ExcelToFoConverter(Document document)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
createPageMaster(float tableWidthIn, String pageMasterName)
protected Document
getDocument()
float
getPageMarginInches()
protected boolean
isEmptyStyle(CellStyle cellStyle)
Returnsfalse
if cell style by itself (without text, i.e.static void
main(String[] args)
Usage: ExcelToHtmlConverter infile outfilestatic Document
process(File xlsFile)
Converts Excel file (97-2007) into XSL FO file.protected boolean
processCell(HSSFWorkbook workbook, HSSFCell cell, Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt)
protected void
processCellStyle(HSSFWorkbook workbook, HSSFCellStyle cellStyle, Element cellTarget, Element blockTarget)
protected void
processCellStyleBorder(HSSFWorkbook workbook, Element cellTarget, String type, BorderStyle xlsBorder, short borderColor)
protected void
processCellStyleFont(HSSFWorkbook workbook, Element blockTarget, HSSFFont font)
protected void
processColumnHeaders(HSSFSheet sheet, int maxSheetColumns, Element table)
protected float
processColumnWidths(HSSFSheet sheet, int maxSheetColumns, Element table)
Creates COLGROUP element with width specified for all columns.protected void
processDocumentInformation(SummaryInformation summaryInformation)
protected int
processRow(HSSFWorkbook workbook, CellRangeAddress[][] mergedRanges, HSSFRow row, Element tableRowElement)
protected Element
processRowNumber(HSSFRow row)
protected boolean
processSheet(HSSFWorkbook workbook, int sheetIndex)
Process single sheet (as specified by 0-based sheet index)protected float
processSheet(HSSFWorkbook workbook, HSSFSheet sheet, Element flow)
protected void
processSheetName(HSSFSheet sheet, Element flow)
void
processWorkbook(HSSFWorkbook workbook)
void
setPageMarginInches(float pageMarginInches)
-
Methods inherited from class org.apache.poi.hssf.converter.AbstractExcelConverter
getColumnName, getColumnWidth, getDefaultColumnWidth, getFontReplacer, getRowName, isOutputColumnHeaders, isOutputHiddenColumns, isOutputHiddenRows, isOutputLeadingSpacesAsNonBreaking, isOutputRowNumbers, isTextEmpty, setFontReplacer, setOutputColumnHeaders, setOutputHiddenColumns, setOutputHiddenRows, setOutputLeadingSpacesAsNonBreaking, setOutputRowNumbers
-
-
-
-
Constructor Detail
-
ExcelToFoConverter
public ExcelToFoConverter(Document document)
-
ExcelToFoConverter
public ExcelToFoConverter(FoDocumentFacade foDocumentFacade)
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Usage: ExcelToHtmlConverter infile outfileWhere infile is an input .xls file ( Word 97-2007) which will be rendered as XSL FO into outfile
- Throws:
Exception
-
process
public static Document process(File xlsFile) throws Exception
Converts Excel file (97-2007) into XSL FO file.- Parameters:
xlsFile
- file to process- Returns:
- DOM representation of result XSL FO
- Throws:
Exception
-
getDocument
protected Document getDocument()
- Specified by:
getDocument
in classAbstractExcelConverter
-
getPageMarginInches
public float getPageMarginInches()
-
isEmptyStyle
protected boolean isEmptyStyle(CellStyle cellStyle)
Returnsfalse
if cell style by itself (without text, i.e. borders, fill, etc.) worth a mention,true
otherwise- Returns:
false
if cell style by itself (without text, i.e. borders, fill, etc.) worth a mention,true
otherwise
-
processCell
protected boolean processCell(HSSFWorkbook workbook, HSSFCell cell, Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt)
-
processCellStyle
protected void processCellStyle(HSSFWorkbook workbook, HSSFCellStyle cellStyle, Element cellTarget, Element blockTarget)
-
processCellStyleBorder
protected void processCellStyleBorder(HSSFWorkbook workbook, Element cellTarget, String type, BorderStyle xlsBorder, short borderColor)
-
processCellStyleFont
protected void processCellStyleFont(HSSFWorkbook workbook, Element blockTarget, HSSFFont font)
-
processColumnHeaders
protected void processColumnHeaders(HSSFSheet sheet, int maxSheetColumns, Element table)
-
processColumnWidths
protected float processColumnWidths(HSSFSheet sheet, int maxSheetColumns, Element table)
Creates COLGROUP element with width specified for all columns. (Except first ifAbstractExcelConverter.isOutputRowNumbers()
==true
)- Returns:
- table width in inches
-
processDocumentInformation
protected void processDocumentInformation(SummaryInformation summaryInformation)
-
processRow
protected int processRow(HSSFWorkbook workbook, CellRangeAddress[][] mergedRanges, HSSFRow row, Element tableRowElement)
- Returns:
- maximum 1-base index of column that were rendered, zero if none
-
processSheet
protected float processSheet(HSSFWorkbook workbook, HSSFSheet sheet, Element flow)
-
processSheet
protected boolean processSheet(HSSFWorkbook workbook, int sheetIndex)
Process single sheet (as specified by 0-based sheet index)- Returns:
true
if result were added to FO document,false
otherwise
-
processWorkbook
public void processWorkbook(HSSFWorkbook workbook)
-
setPageMarginInches
public void setPageMarginInches(float pageMarginInches)
-
-