Free Support Forum - aspose.com

How do I import data with htm l format tags on text

Dear all,
I need some help on getting text with additional html format tags into an excel file. Currently I read data out of the database into a datatable. Then I import the data into a new Worksheet with ImportDataTable…
Now i’m looking for a way to get a new column into the worksheet. The text to be imported has html tags. I already found the Cell.HtmlString but could not find a way to use this.
My program is a dynamic process which reads from different views on my database and creates excel exports.

Is there a way to run through a column and set the HtmlString on all the cells ?
Or maybe better an eventhandle i can use on the ImportDataTable ?

THX for any help!

Hi,


Thanks for your query.

First of all not all the HTML tags are supported. In MS Excel some limited HTML tags are supported (only basic tags are supported in MS Excel), so Aspose.Cells cannot parse all HTML tags as it follows Ms Excel standards and specifications. you may open and render HTML files in MS Excel but the HTML should be MS Excel oriented, this is not completely a common HTML.

I think you are using Cells.ImportDataTable() method to import data from your data source to paste into the worksheet. Well, I am afraid, there is no specific option available in Cells.ImportDataTable() method where you could set HTML parsing on. so you got to do it yourself via Cell.HtmlString attribute once you have imported data into the worksheet. I think you may loop through the cells in your HTML columns and specify Html string for the simple string/data to be set, see the sample code segment below:
e.g
Sample code:

int mRow = 10;

//Browse the cells in the A column.
for (int i = 0; i <= mRow; i++)
{
Aspose.Cells.Cell cell = cells[i, 0];
cell.HtmlString = cell.StringValue;


}


By the way, you may also try to use our Smart Markers feature if you want. It does support to parse HTML while importing/processing data for the markers into the worksheet, see the document for your complete reference:
http://www.aspose.com/docs/display/cellsnet/Smart+Markers
(Note: see the description text and example code specially under the bottom heading “Using HTML property of Smart Markers”).

Thank you.