Free Support Forum - aspose.com

Rich Text Formatting

We need to know about the Rich Text Formatting options in Aspose Cells.


We need to import HTML (Rich Text data) from Database to Excel using Aspose Cells. The HTML is stored in Oracle DB as Clob.I have attached a sample text file with all possible formatting that a user can do with the UI.

Please do provide us with an exhaustive list of HTML Tags that are supported. I have read many documentation and it looks that NOT all formatting options are supported.

Thanks in advance.

Regards,

Shri Prakash C

Hi,


Well, Aspose.Cells is mainly an MS Excel spreadsheet management library, it can read and write HTML files but those HTML files are more like MS Excel oriented rather than general/common HTMLs. Moreover, to read/write common/general HTML files (with all its flavors/html tags) is not its strong feature by any means. To test your issue, I just opened your “RichTextWithTablesAndImages.txt” file into notepad and then Save it as “RichTextWithTablesAndImages1.html”. Now open that file into MS Excel and changed the picture’s source link in the sheet to valid link, now resave the file. This would surely create an extra “RichTextWithTablesAndImages1_files” folder with its relative source files (including picture etc.).

Now I used the following sample code to load the HTML file (attached) to save to XLSX (attached) file, it works fine. So, there is no issue if the HTML file is MS Excel oriented.

Sample code:

string stream = “e:\test2\RichTextWithTablesAndImages1.html”;
LoadOptions loadOptions = new LoadOptions(LoadFormat.Html);
Workbook htmlWorkbook = new Workbook(stream, loadOptions);

htmlWorkbook.Save(“e:\test2\outExcel1.xlsx”);



And, I am using latest fix/version: Aspose.Cells for .NET v7.3.4.2

Thank you.

Is it possible to share the output Excel file ?

Missed to see the attachments…Sorry about that. Will get back if i have anything else.

ShriPrakash:
Missed to see the attachments..Sorry about that. Will get back if i have anything else.
Hi,

Thanks for your posting and using Aspose.Cells.

Let us know if you still find any issue. We will be glad to look into your reported issues and help you asap.

Besides, we have lately done some major enhancements and added new features in our product, so you should also download and give a try to latest offline demos of Aspose.Cells which you can find from theses links.

These demos can work with Visual Studio 2005, 2008 or 2010. Please read the readme.txt file before running the demos.


Thanks for the support.

I saved the HTML string from Database as an HTML file (programmatically) and used the sample code provided, I was able to display the content but NOT as expected.

//Retrieve Rich Text data from DB
string htmlstring = LoadRichTextData();

//Save the content as HTML file
using (FileStream fs = new FileStream(@"C:\Users\157074\Desktop\RichTextAsposeCells\SampleHTML.htm", FileMode.Create))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(htmlstring);
}
}

//Load the HTML File to Excel
string stream = @"C:\Users\157074\Desktop\RichTextAsposeCells\SampleHTML.htm";
LoadOptions loadOptions = new LoadOptions(LoadFormat.Html);
Workbook htmlWorkbook = new Workbook(stream, loadOptions);

//Save the file
htmlWorkbook.Save(@"C:\Users\157074\Desktop\RichTextAsposeCells\ExcelOutputForSampleHTML.xlsx");

Please see attachments.

ShriPrakash:

Thanks for the support.

I saved the HTML string from Database as an HTML file (programmatically) and used the sample code provided, I was able to display the content but NOT as expected.

//Retrieve Rich Text data from DB
string htmlstring = LoadRichTextData();

//Save the content as HTML file
using (FileStream fs = new FileStream(@"C:\Users\157074\Desktop\RichTextAsposeCells\SampleHTML.htm", FileMode.Create))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(htmlstring);
}
}

//Load the HTML File to Excel
string stream = @"C:\Users\157074\Desktop\RichTextAsposeCells\SampleHTML.htm";
LoadOptions loadOptions = new LoadOptions(LoadFormat.Html);
Workbook htmlWorkbook = new Workbook(stream, loadOptions);

//Save the file
htmlWorkbook.Save(@"C:\Users\157074\Desktop\RichTextAsposeCells\ExcelOutputForSampleHTML.xlsx");

Please see attachments.

Hi,

Thanks for your posting and using Aspose.Cells.

Not every type of html can be successfully converted to workbook by Aspose.Cells. Only the standard html generated by Ms-Excel can be converted to workbook with Aspose.Cells.

Please make sure, your html is a standard html (as generated by Ms-Excel). You can manually create your desired worksheet in Ms-Excel and then save it back in html format. It will give you standard html page which you can then load using Aspose.Cells and convert it into workbook.

Once, you know how to generate standard html, you can then use it as per your requirements by modifying existing standard html template.