We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exporting HTML tables to Excel


I am a beginner and i want to export a HTML generated table to excel.

An example HTML is

<html xmlns="http://www.w3.org/1999/xhtml">

<head><title>Product Information</title>

<style>.border, .border td {border: 1px solid ; }</style>


<form name="form1" method="post" action="" >

<div align="center">

<span id="lbl_header" style="font-size:X-Large;">Products Overview</span>


<span style="font-size:Large;">Product:Milk</span>

<table id="tbl_steplevel" border="0" class="border">

<tr valign="top">

<td rowspan="2">productid</td><td rowspan="2">No.of categories</td><td rowspan="2">No. of countries</td><td colspan="4">category1</td><td colspan="4">category2</td>

</tr><tr valign="top">

<td >produced</td><td >%</td><td >sold</td><td >%</td><td >produced</td><td >%</td><td >sold</td><td >%</td>

</tr><tr valign="top">




Can i directly export using Data export methods, or do i need to create Aspose cells manually and using putvalue to export data to excel.




Well, currently, Aspose.Cells for .NET does not parse html tags to import data to Worksheets although you may convert an excel file (xls/xlsx) to save as .html file formats using e.g…, workbook.Save(“d:\test\myfile.html”,FileFormatType.Html); We willl look into the feature soon.

And, yes, you do need to use Cell.PutValue() method to manually export data to excel spreadsheet.

Thank you.

Thanks for the reply.

I am using CreateRange to create headers for the table.

As in the example HTML code, u have seen category1, category2. How can i use createrange to add headers like category).

I mean is there an equivalent property like rowspan, colspan for cells.



Well, I think you may try to merge / unmerge the cells using Cells.Merge() and Cells.Unmerge() methods. If you are creating some ranges, you may utilize Range.Merge() method to merge a range as well. Moreover, you may use Cells.SetColumnWidth and Cells.SetRowHeight methods to extend cells heights and widths to format a table for your need.

For your reference, please check the following doc topics:




Thank you.