Class ToHtml


  • public final class ToHtml
    extends Object
    This example shows how to display a spreadsheet in HTML using the classes for spreadsheet display.
    • 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" an XSSFWorkbook will be used; otherwise this will use an HSSFWorkbook.
        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 an XSSFWorkbook or not (so it should create an HSSFWorkbook).
        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)
      • 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