Package org.apache.poi.examples.ss.html
Class ToHtml
- java.lang.Object
-
- org.apache.poi.examples.ss.html.ToHtml
-
public final class ToHtml extends Object
This example shows how to display a spreadsheet in HTML using the classes for spreadsheet display.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ToHtmlcreate(InputStream in, Appendable output)Creates a new examples to HTML for the given workbook.static ToHtmlcreate(String path, Appendable output)Creates a new examples to HTML for the given workbook.static ToHtmlcreate(Workbook wb, Appendable output)Creates a new examples to HTML for the given workbook.static voidmain(String[] args)Run this class as a programvoidprint()voidprintPage()voidprintSheet(Sheet sheet)voidprintStyles()voidsetCompleteHTML(boolean completeHTML)protected intwidthToPixels(double widthUnits)Probably platform-specific, but appears to be a close approximation on some systems
-
-
-
Method Detail
-
create
public static ToHtml create(Workbook wb, Appendable output)
Creates a new examples to HTML for the given workbook.- Parameters:
wb- The workbook.output- Where the HTML output will be written.- Returns:
- An object for converting the workbook to HTML.
-
create
public static ToHtml create(String path, Appendable output) throws IOException
Creates a new examples to HTML for the given workbook. If the path ends with ".xlsx" anXSSFWorkbookwill be used; otherwise this will use anHSSFWorkbook.- Parameters:
path- The file that has the workbook.output- Where the HTML output will be written.- Returns:
- An object for converting the workbook to HTML.
- Throws:
IOException
-
create
public static ToHtml create(InputStream in, Appendable output) throws IOException
Creates a new examples to HTML for the given workbook. This attempts to detect whether the input is XML (so it should create anXSSFWorkbookor not (so it should create anHSSFWorkbook).- Parameters:
in- The input stream that has the workbook.output- Where the HTML output will be written.- Returns:
- An object for converting the workbook to HTML.
- Throws:
IOException
-
main
public static void main(String[] args) throws Exception
Run this class as a program- Parameters:
args- The command line arguments.- Throws:
Exception- Exception we don't recover from.
-
setCompleteHTML
public void setCompleteHTML(boolean completeHTML)
-
printPage
public void printPage() throws IOException- Throws:
IOException
-
print
public void print()
-
printStyles
public void printStyles()
-
printSheet
public void printSheet(Sheet sheet)
-
widthToPixels
protected int widthToPixels(double widthUnits)
Probably platform-specific, but appears to be a close approximation on some systems- Parameters:
widthUnits- POI's native width unit (twips)- Returns:
- the approximate number of pixels for a typical display
-
-