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; HtmlSaveOptions options = new HtmlSaveOptions(); options.ExportHiddenWorksheet = false; options.ExportPrintAreaOnly = true; Style style = worksheet.Cells.Columns.Style; style.IsTextWrapped = true; StyleFlag styleFlag = new StyleFlag(); styleFlag.WrapText = true; worksheet.Cells.Columns.ApplyStyle(style, styleFlag); workbook.Save("exampleAspose.html", options);
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)
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.
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.
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)
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
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.