HtmlString property issues

HI,



My company is about to purchase Aspose Total, and I’m evaluating Aspose.Cells.Cell.HtmlString property features, and I found two blocking problems:



1) Given a formatted HTML text created/edited by WebBrowser control EditMode=“On”, whitch sets the font size on the following way: …

Aspose.Cells.Cell.HtmlString property realizes it as size “2pt” in point unit, but according to W3C definition, it’s just “Size 2” on an 1-7 scalar level scale:

Alignment, font styles, and horizontal rules in HTML documents

http://www.w3schools.com/tags/att_font_size.asp





My approximate matching between 1-7 scalar level scale and point unit is the following based on Times New Roman in IE11: 1: 7pt; 2: 10pt; 3: 12pt; 4: 14pt; 5: 18pt; 6: 24pt 7: 36pt – I couldn’t find any official matching.



2) Aspose.Cells.Cell.HtmlString property does not support multiline formatted texts. It seems it just skips p, div, br HTML tags. Our customers do need multiline formatted texts, if HtmlString property does not support this, our team just cannot use the Aspose.Cells library.



I’ve attached a code sample “ConsoleApplication1.zip” which demonstrates both issues. The “Excel.Result.Aspose.jpg” attachment shows the Aspose.Cells library result, the “Excel.Result.Expected.jpg” attachment shows the correct, expected result.



Thank you!



Best regards,

Aron Kolozs

Hi,

Thanks for your posting and considering Aspose.Cells.

Aspose.Cells does not support all the HTML, it just supports specific HTML that is generated by Microsoft Excel. For your purpose, you can manually create your formatted text using Microsoft Excel and observe what HTML was generated using Aspose.Cells APIs. Then you can use that same HTML to recreate your cell.

For multi line text, you must wrap the text of the cell via Style.IsTextWrapped property as shown in the code.

Please see the following sample code and its console output as well as the source excel file and output excel file generated by it for your reference. I have also shown the cell A2 created by Aspose.Cells in a screenshot.

C#

Workbook wb = new Workbook(“Book1.xlsx”);

Worksheet ws = wb.Worksheets[0];

Cell c = ws.Cells[“A1”];

Cell c2 = ws.Cells[“A2”];

//Please use this HTML
Console.WriteLine(c.HtmlString);
Debug.WriteLine(c.HtmlString);

c2.HtmlString = c.HtmlString;

Style s2 = c2.GetStyle();
s2.IsTextWrapped = true;
s2.HorizontalAlignment = TextAlignmentType.Center;
c2.SetStyle(s2);

ws.AutoFitRow(1);

wb.Save(“output.xlsx”);

Console Output
Gebäude: € 22.400.450,00
Schad, max.