Exporting to HTML
Spread WinRT Documentation > Developer's Guide > Managing Data > Exporting to HTML

Cell values, cell style information, spans, multiple headers, grid lines, grid line colors, and the control theme are saved to the HTML file.

The file contains the area down to the last cell with data.

The column width may be expanded in order to display all the text in the cell. Hidden rows and columns are also hidden in the HTML file.

Sparklines, group bars, the filter button, the sheet corner arrow, and the tab strip are not exported. Cell word wrap, cell overflow, frozen rows and columns, active cell outline, and the zoom option are also not exported.

If there are multiple viewports, the default viewport is saved.

You can use the SaveHtmlAsync method in code to save to an HTML file.

Using Code

This example saves a file to HTML.

CS
Copy Code
private void Grid_Loaded_1(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.Sheets[0].ShowGridLine = true;
            gcSpreadSheet1.Sheets[0].GridLineColor = Windows.UI.Colors.BurlyWood;
            gcSpreadSheet1.Sheets[0].Cells[0, 0].Text = "test";
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileSavePicker();
                filePicker.FileTypeChoices.Add("HTML Files", new List<string>() { ".html" });
                filePicker.SuggestedFileName = "New SpreadSheet File";
                Windows.Storage.StorageFile storageFile = await filePicker.PickSaveFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForWriteAsync())
                    {
                        var fileName = storageFile.FileType.ToUpperInvariant();
                       await gcSpreadSheet1.Sheets[0].SaveHtmlAsync(stream);
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }          
        }
VB
Copy Code
Private Sub MainPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        gcSpreadSheet1.Sheets(0).ShowGridLine = True
        gcSpreadSheet1.Sheets(0).GridLineColor = Windows.UI.Colors.BurlyWood
        gcSpreadSheet1.Sheets(0).Cells(0, 0).Text = "test"
    End Sub
    Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Try
            Dim filePicker As New Windows.Storage.Pickers.FileSavePicker()
            filePicker.FileTypeChoices.Add("HTML Files", New List(Of String)() From {".html"})
            filePicker.SuggestedFileName = "New SpreadSheet File"
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSaveFileAsync()
            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForWriteAsync()
                    Dim fileName = storageFile.FileType.ToUpperInvariant()                   
                   await gcSpreadSheet1.Sheets(0).SaveHtmlAync(stream)
                End Using
            End If
        Catch ex As Exception
            Dim dialog As Windows.UI.Popups.MessageDialog = New Windows.UI.Popups.MessageDialog(ex.Message, "Error")
            dialog.ShowAsync()
        End Try
    End Sub
See Also