Spread 8.0 Documentation
Exporting to an HTML File
Support Options
User's Guide > Working with the Control > Saving Data > Exporting to an HTML File

Glossary Item Box

Exporting to an HTML File


Overview

You can export a cell, a block of cells, a column, a row, or an entire sheet to an HTML file. Data and property settings are translated into HTML as explained in HTML File Export Reference.

You can also export discontiguous cells, blocks of cells, columns, and rows by performing one of the following actions:

For example, assume your sheet has 15 rows and you want to export only the subtotals of your sheet (rows 5, 10, and 15) to an HTML file. You could use the following code to hide all rows except the subtotal rows and then export rows 5, 10, and 15.

Sub Form_Load
    Dim i As Integer
    Dim rc As Integer
    fpSpread1.MaxRows = 15
    For i = 1 to 15
        fpSpread1.Row = i
        If i = 5 Or i = 10 Or i = 15 Then
            fpSpread1.RowHidden = False
        Else
            fpSpread1.RowHidden = True
        End If
    Next i
    rc = fpSpread1.ExportToHTML("c:\subtotal.htm", 0, "c:\mylog.txt")
End Sub

You could also use the following code to append rows 10 and 15 to row 5.

SpreadExportRangeToHTML(1, 5, -1, 5, "c:\subtotal.htm", 0, "c:\mylog.txt")
SpreadExportRangeToHTML(1, 10, -1, 10, "c:\subtotal.htm", 1, "c:\mylog.txt")
SpreadExportRangeToHTML(1, 15, -1, 15, "c:\subtotal.htm", 1, "c:\mylog.txt")

When you export discontiguous cells, blocks of cells, columns, or rows,

For example, assume you have the following data and you want to export blocks A1:B3 and D4:E5.

The code to export the blocks is:

SpreadExportRangeToHTML(1, 1, 2, 3, "c:\block.htm", 0, "c:\mylog.txt")
SpreadExportRangeToHTML(4, 4, 5, 5, "c:\block.htm", 1, "c:\mylog.txt")

The resulting HTML file would appear like this.

Notice that the blank cell E4 is exported and column and row headers display for each range that is exported. Row headers also re-number so that the row numbering sequence is correct.

Tip: After the first export, set the ColHeadersShow property to False to have subsequent exports just export the data, not the column headers. When finished, set the ColHeadersShow property to True.

You can also use style settings from a CSS file when exporting to HTML using the ExportToHTMLEx or ExportRangeToHTMLEx methods.

By default, the file created by exporting to an HTML file has the extension .HTM; however, you can use any extension when you export from the fpSpread control or the Spread Designer.

Tip: Because you cannot import the HTML file you save back into the Spread control, you might want to save to a Spread (.SS8) file in addition to exporting it to HTML. If you want to make future modifications, you can open the Spread (.SS8) file and then resave it to HTML.

Notes:
  • You can use the URL function in a cell formula to create a hypertext link in the exported HTML file. The link can display either a complete URL address (for example, http://www.fpoint.com) or a descriptive name (for example, FarPoint). For more information, see "URL" in Formula Operators and Functions.
  • The Spread version 6 ActiveX controls are safe for scripting. If you are using the Spread ActiveX control in a container that supports IObjectSafety such as Internet Explorer 4, you cannot export or save files.
  • Turn off virtual mode before exporting to an HTML file.

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.