Save Worksheet as HTML

I have Aspose Cells for .NET ver 4.8.0.0 and was wondering if there is a way to save a Worksheet as a stand alone HTML file? I have used the workbook Save() method with FileFormatType.Html, but the worksheet html files contain links to the tabstrip, and parent html file which I would prefer not to have in the HTML.

Thanks
Patrick

Hi,

Well, Aspose.Cells for .NET follows the MS Excel standard, it generates MS Excel oriented html/htm files with its all inter-dependencies having a parent html file with individual html files (regarding different worksheets) and xml files (etc). in a folder. In MS Excel, if you save a workbook as html / web page etc, you can see all these files are generated, so, Aspose.Cells for .NET works in the same way as MS Excel does.

Thank you.

That is true for saving a Workbook as HTML, but MS Excel does give you the option to save just one Worksheet from a Workbook as a standalone HTML file. I was simply wondering if this was possible with Aspose Cells.

Thanks
Patrick

Hi Patrick,

Well, I think, as a workaround, you may remove the unwanted worksheets in the workbook (dynamically) just for sake of rendering your desired worksheet only as a standalone (similar to MS Excel) html file. See the sample code below:

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(“Aspose.Cells.lic”);
Workbook workbook = new Workbook();
workbook.Open(“e:\test\Book1.xls”);
//Suppose the workbook has three sheets in it.
//If you want to render only first worksheet as a standalone html file, you may
//delete second and third worksheets (as a workaround) temporarily.
int i = workbook.Worksheets.Count - 1;
do
{
workbook.Worksheets.RemoveAt(i);
i = workbook.Worksheets.Count - 1;
} while (i > 0);
workbook.Save(“e:\test\mysheetfile.html”, FileFormatType.Html);

Thank you.

Hi,

Alternatively, it would be better you use the overloaded version of the method, check the description of the method, i.e…,
Workbook.Save(string fileName, bool isWhole, string title)
///


/// Export the workbook to Html file.
///

/// Text file name.
/// Indicates whether export the whole workbook or only the active sheet.
/// The title of the html page.


Here is my example code which works fine.


Aspose.Cells.License license = new Aspose.Cells.License();

license.SetLicense(“Aspose.Cells.lic”);
Workbook
workbook = new Workbook();

workbook.Open(“e:\test\Book1.xls”);
//Suppose the
workbook has three sheets in it.
//If you want to render
only first worksheet as a standalone html file.
workbook.Worksheets.ActiveSheetIndex = 0;

workbook.Save(“e:\test\mysheetfile.html”, false, “MyTitle”);


Thank you.