Aspose.Cells conversion. Text wrapping

Hello.

I convert excel file to HTML.
File: example.zip (9.1 KB)
Table cell has “Wrap” option enabled:
image.png (38.8 KB)
But the converted HTML file displays such a cell on one line.
Aspose.Cells v 21.9.0

@Andrei86,
You may please give a try to the following sample code and share your feedback.

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook("example.xls");
Worksheet worksheet = workbook.Worksheets[0];
HtmlSaveOptions options = new HtmlSaveOptions();
options.ExportHiddenWorksheet = false;
options.ExportPrintAreaOnly = true;
Style style = worksheet.Cells.Columns[2].Style;
style.IsTextWrapped = true;
StyleFlag styleFlag = new StyleFlag();
styleFlag.WrapText = true;
worksheet.Cells.Columns[2].ApplyStyle(style, styleFlag);
workbook.Save("exampleAspose.html", options);

@Andrei86

The Cell C19 is not wrap text, the horizontal alignment “Justify” makes it like wrap text. justify_alignment.png (44.8 KB)

You can change the horizontal alignment to see the difference.

By the way, if you manually save the file to html in Mircrosoft Excel, the text is also no wrapped.

I can’t modify file content because I convert to HTML any provide file.
Converted by Aspose HTML file looks strange
image.png (63.2 KB)
Td style
Text-align: justify
white-space: nowrap
If set white-space: normal HTML will look like excel file.
Why does Aspose set nowrap in this case?
The content in a cell appears as multiline text in Excel, and the corresponding button is highlighted as active on the toolbar.

@Andrei86,

Aspose.Cells follows MS Excel standards and specifications when parsing or rendering to HTML. You may render Excel file to HTML in MS Excel manually and you will get almost similar results. So, it is not an issue with the APIs.

As suggested, either set wrap text on in MS Excel (manually) or use suggested sample code (in one of the previous post) to set wrapping text on while applying style for your needs.

Thanks for clarification.

I have one more question.
This file after conversation has incorrect view:
example_file.zip (235.1 KB)
Aspose: image.png (10.4 KB)
Converted by Excel: image.png (12.3 KB)

The text does not overlap data from a sibling cell in version converted by Excel.
I use version 21.09. The same actual for 21.10

MS Office and Aspose mark up difference:
image.png (67.5 KB)

@Andrei86,
We have observed this issue and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSNET-49624 - Text wrapping issue during XLSX to HTML conversion

@Andrei86,
The root cause is that the set font “Microsoft Sans Serif” don’t contain Chinese glyphs (e.g. Cell F6), in this case, we can’t measure text width correctly.
Currently we can’t fix the issue. Please change the font(e.g. “宋体”) in the source file if possible.

@Andrei86,

This is to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v23.5) that we plan to release in the first half of May2023. You will be notified when the next version is released.
Here is the sreenshot of result generated after fix:CELLSNET-49624.zip (189.2 KB)

The issues you have found earlier (filed as CELLSNET-49624) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi