We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text does not appear outside of cell

Hello,

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:

Cut off text in Aspose Cells.pdf (48.6 KB)

Is there any setting I can use to prevent this?

Thanks,
Victor

@VMOHA,

Thanks for the sample PDF file.

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:
https://docs.aspose.com/display/cellsnet/AutoFit+Rows+and+Columns

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);
...........

Hope, this helps a bit.

Hello Amjad,

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?

Very Best Regards,
Victor

@VMOHA

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");

Screenshot

Ah, so I see. This was definitely the issue and, when I no longer output blank text into a cell, this worked flawlessly. Many thanks, Shakeel!

@VMOHA

Thanks for using Aspose APIs.

It is good to know that your issue is resolved now. Let us know if you encounter any other issue, we will be glad to help you further.