My apologies if this question has been asked and I have not found the answer to it. I am creating a new Excel Workbook purely using Aspose Cells. I am finding that there is no overflow resulting in text being cutoff as can be seen here:
I can see some part of text in the cells are hidden or not shown because the column’s width is less. A better way to cope with it is you should use Worksheet.AutoFitColumn/AutoFitColumns method(s), see the document for your reference:
Also, see the sample line of code for your reference:
e.g Sample code:
..........
//Extend/fit the column's width in accordance with longest value of cell(s) to display the text/value fully.
//AutFit the first column in the first worksheet. You may apply autofit operation for your specified worksheet accordingly.
workbook.Worksheets[0].AutoFitColumn(0);
...........
Thanks for the reply. It is by-design that the column width is less than the text. In Excel with an Interop and Office Open XML the text shows despite the column’s length being smaller. Does Aspose offer similar functionality?
Text in cell will only overflow if the next cell in next column is empty. Please see the following sample code, read its comment and check the screenshot that explains why text in cell A5 overflows. When B5 is empty, A5 text overflows but when B5 is non-empty, the text does not overflow.
C#
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];
ws.Cells["A3"].PutValue("This text is long so it will overflow.");
ws.Cells["A5"].PutValue("This text is long but it will overflow. Because next cell B5 is not empty.");
//Comment this line to see effect on the output Excel file
ws.Cells["B5"].PutValue("");
wb.Save("output1.xlsx");