Hi,
we use aspose words, aspose pdf & aspose cells product at our work. We have a requirement to convert complex html along with its styles in to excel ,
what is the best way to approach this ?
I tried the below three
1.“var workbook = new Workbook(new MemoryStream(Encoding.UTF8.GetBytes(html)));
var resp = new MemoryStream();
workbook.Save(resp, SaveFormat.Xlsx);”
I dont see the expected output (lot of styles are lost)
2.I tried htmlString at cell level which lead to string size limitation error
3.i tried inserting image (converted html to img via aspose words product) but that has accessiblity issues (E.g. searching for a text )
@gouthamrangarajan,
Generally, Aspose.Cells follows MS Excel standards and specifications when parsing and rendering HTML files. Aspose.Cells supports creating and rendering MS Excel-oriented HTML files. So, when you specify HTML strings/tags in the file, this should be supported in MS Excel, or MS Excel should parse it fine. For your information, not all HTML tags or common HTML are supported by MS Excel or Aspose.Cells. Aspose.Cells can parse those HTML tags which are understood/parsed by MS Excel.
Anyways, could you please zip and attach your input HTML file and output XLSX file for reference? We will check it soon.
Thank you , ill try to prepare a sample and share
test_to_aspose.zip (6.2 KB)
Here is a sample, due to constraints i wont be able to share the whole html ,but i created a very simple sample which does not gives expected output
i tried the below code
" var workbook = new Workbook(new MemoryStream(Encoding.UTF8.GetBytes(html)));
var resp = new MemoryStream();
workbook.Save(resp, SaveFormat.Xlsx);"
@gouthamrangarajan
By testing with the latest version v24.1, we can obtain the same results as MS Excel. Please refer to the attachment. result.zip (75.7 KB)
The sample code as follows:
Workbook wb = new Workbook(filePath + "test_to_aspose.html");
wb.Save(filePath + "out_net.xlsx");
If you have any questions or confusion, please provide screenshots and highlight the incorrect areas, which will be helpful for us to locate the issue.
Thank you we are currently using v21.2.0, ill try with v24.1.0 and keep you posted
hi,
just tried it out and got the below error
image.png (25.2 KB)
unfortunately it might take time (due to multiple teams communciation) to upgrade license, is there any way i can achieve it in v21.2.0 ?
or answer to my first question would be helpful
"Best way to display complex html in excel cell using v21.2.0 "
@gouthamrangarajan,
We cannot include enhancements/fixes to older versions, the fixes/enhancements are done based on latest APIs set only. Since your license is expired, so you cannot use newer versions of the API with your current license (as the error suggests). You have to upgrade your subscription to use newer versions.
By the way, you may open your HTML file into MS Excel manually and check how it is displayed (please check the screenshot in the zipped archive attached by @John.He in his post). Aspose.Cells will render the same display (it mimics MS Excel) in the output XLSX from source HTML.
Thank you for your response and thanks for the tip (opening html in excel)
Cheers
@gouthamrangarajan
You are welcome. If you have any questions, please feel free to contact us.