I’m having problems using AutoFitColumn method in my application - in many cases column width is too small. I’ve created a sample application to test this method. It seems that AutofitColumn in my example does nothing at all. Could you please check this out?
My sample code (autofit.xls attached):
Aspose.Cells.Workbook wbk=new Aspose.Cells.Workbook();
Generally my problem with AutoFitColumn is that width is too small. I used to fix this by expanding width by 10%. But it seems that it is not enough in some cases. I know that this function is not precise (based on documentation). But is there a reasonable way of ensusing that column width is wide enough to display all the data?
Here’s output xls.
This problem is caused by "Wrap Text" settings. Please right-click the first column and choose "Format Cells", then please uncheck "Wrap Text" option in Alignment setting window. Then all will be fine.
I will check this issue and make AutoFitColumn method also working for checked "Wrap Text" setting.
Ok, when I do this. AutoFit works fine.
But I can’t change wrap text property programatically.
I added new line to my sample code:
and the result is the same since style has not changed.
Please change your code to:
for(int i = 0; i <= 200; i ++)
wbk.Worksheets["Test"].Cells[i, 0].Style.IsTextWrapped = false;