Package org.apache.poi.hssf.converter
Class ExcelToHtmlConverter
java.lang.Object
org.apache.poi.hssf.converter.AbstractExcelConverter
org.apache.poi.hssf.converter.ExcelToHtmlConverter
Converts xls files (97-2007) to HTML file.
- Author:
- Sergey Vladimirov (vlsergey {at} gmail {dot} com)
-
Field Summary
Fields inherited from class org.apache.poi.hssf.converter.AbstractExcelConverter
_formatter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
buildStyle
(HSSFWorkbook workbook, HSSFCellStyle cellStyle) protected String
getStyleClassName
(HSSFWorkbook workbook, HSSFCellStyle cellStyle) boolean
static void
Java main() interface to interact withExcelToHtmlConverter
static Document
Converts Excel file (97-2007) into HTML file.static Document
process
(InputStream xlsStream) Converts Excel file (97-2007) into HTML file.static Document
process
(HSSFWorkbook workbook) Converts Excel file (97-2007) into HTML file.protected boolean
processCell
(HSSFCell cell, Element tableCellElement, int normalWidthPx, int maxSpannedWidthPx, float normalHeightPt) protected void
processColumnHeaders
(HSSFSheet sheet, int maxSheetColumns, Element table) protected void
processColumnWidths
(HSSFSheet sheet, int maxSheetColumns, Element table) Creates COLGROUP element with width specified for all columns.protected void
processDocumentInformation
(SummaryInformation summaryInformation) protected int
processRow
(CellRangeAddress[][] mergedRanges, HSSFRow row, Element tableRowElement) protected void
processRowNumber
(HSSFRow row, Element tableRowNumberCellElement) protected void
processSheet
(HSSFSheet sheet) protected void
processSheetHeader
(Element htmlBody, HSSFSheet sheet) void
processWorkbook
(HSSFWorkbook workbook) void
setCssClassPrefixCell
(String cssClassPrefixCell) void
setCssClassPrefixDiv
(String cssClassPrefixDiv) void
setCssClassPrefixRow
(String cssClassPrefixRow) void
setCssClassPrefixTable
(String cssClassPrefixTable) void
setUseDivsToSpan
(boolean useDivsToSpan) Allows converter to wrap content into two additional DIVs with tricky styles, so it will wrap across empty cells (like in Excel).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 Details
-
ExcelToHtmlConverter
-
ExcelToHtmlConverter
-
-
Method Details
-
main
Java main() interface to interact withExcelToHtmlConverter
Usage: ExcelToHtmlConverter infile outfile
Where infile is an input .xls file ( Word 97-2007) which will be rendered as HTML into outfile- Throws:
Exception
-
process
Converts Excel file (97-2007) into HTML file.- Parameters:
xlsFile
- workbook file to process- Returns:
- DOM representation of result HTML
- Throws:
IOException
- If an error occurs reading or writing filesParserConfigurationException
- If configuration is incorrect
-
process
public static Document process(InputStream xlsStream) throws IOException, ParserConfigurationException Converts Excel file (97-2007) into HTML file.- Parameters:
xlsStream
- workbook stream to process- Returns:
- DOM representation of result HTML
- Throws:
IOException
- If an error occurs reading or writing filesParserConfigurationException
- If configuration is incorrect
-
process
public static Document process(HSSFWorkbook workbook) throws IOException, ParserConfigurationException Converts Excel file (97-2007) into HTML file.- Parameters:
workbook
- workbook instance to process- Returns:
- DOM representation of result HTML
- Throws:
IOException
- If an error occurs reading or writing filesParserConfigurationException
- If configuration is incorrect
-
buildStyle
-
getCssClassPrefixCell
-
getCssClassPrefixDiv
-
getCssClassPrefixRow
-
getCssClassPrefixTable
-
getDocument
- Specified by:
getDocument
in classAbstractExcelConverter
-
getStyleClassName
-
isUseDivsToSpan
public boolean isUseDivsToSpan() -
processCell
-
processColumnHeaders
-
processColumnWidths
Creates COLGROUP element with width specified for all columns. (Except first ifAbstractExcelConverter.isOutputRowNumbers()
==true) -
processDocumentInformation
-
processRow
- Returns:
- maximum 1-base index of column that were rendered, zero if none
-
processRowNumber
-
processSheet
-
processSheetHeader
-
processWorkbook
-
setCssClassPrefixCell
-
setCssClassPrefixDiv
-
setCssClassPrefixRow
-
setCssClassPrefixTable
-
setUseDivsToSpan
public void setUseDivsToSpan(boolean useDivsToSpan) Allows converter to wrap content into two additional DIVs with tricky styles, so it will wrap across empty cells (like in Excel).Warning: after enabling this mode do not serialize result HTML with INDENT=YES option, because line breaks will make additional (unwanted) changes
-