Free Support Forum - aspose.com

Autofitcolumn

Hi,

I have a column of cells, which are currency and bold and font as 10. when I use autofitcolumn, it gives me ####. The width is smaller than actual string.

I understand the difficulty of implementing autofit method. Any other way I can work around?

Thank you

I emailed you the worksheet. Thank you

Are you Alan?

I got your file. To autofit columns which containing formulas, you may have to calcualte the result at first.

Excel excel = new Excel();

excel.Open("d:\\oooo.xls");


excel.CalculateFormula();

excel.Worksheets[1].AutoFitColumn(8);

excel.Worksheets[1].AutoFitColumn(16);

Hi Laurence,

I tried calculate first, then autofit the columns. It does not work. Is there any other way I can set the width without hard coding the columnwidth?

Have you tried my code and still doesn’t work? I tried it and it’s fine in my machine. Which version are you using? Is it the latest v3.0.2?

Hi, I used your code b4, it did not work.
I opened an oooo.xls, calculateformula, autofit columns. The subtotal was still showing #####. The version I am using is 3.0.2.0

Is that a MS-excel setting?

I am using
Aspose Excel 3.0.2.0
MS-excel 2003 to open the worksheet
Microsoft Visual Basic .NET as development tool

Also one more question about calculateformula method.

If my MS-Excel is set to manual calculation. Which can be setup from tools-> options->tab calculation.

If my ms-excel is set as manual, the formula will not be calculated even if I use calculateformula method.

1. Please set to automatical calculation in MS Excel for Aspose.Excel caculation engine only supports a small part of functions.

2. AutofitColumn works fine in my place. I will send you a program to show how it works. Please try it in a machine without installing Aspose.Excel to avoid version conflicts. I also send your designer file and my generated file.

Dim excel As Excel = New Excel()
excel.Open("c:\oooo.xls")

excel.CalculateFormula()
excel.Worksheets(1).AutoFitColumn(8)
excel.Worksheets(1).AutoFitColumn(16)
excel.Save("c:\result.xls")

How do I use autofit.exe file? Stick out tongue

I opened oooo.xls and result.xls. The I column and Q column in result.xls are still displayed as ########, but the space looks like little bit wider than the I and Q columns in oooo.xls.

The I and Q columns in result.xls have width 13.29 (98 pixels)
The I and Q columns is oooo.xls have width 10.43(78 pixels)

Do u think it maybe the different units system we are using? I saw a post listed the problem about margin issues. Do u think autofit may due to the same reason?

Thank you for your quick response.

Yes. The width of I and Q columns is 13.29(98 pixels). And it shows perfectly on my machine.

Please check the attached screenshot. Could you please upload your screenshoot here? Thank you.

is total bold? on my sheet, it is bold

Yes. I61 and Q61 in my result.xls are all bold.

weird, here are the screen shots.

one more again

Also, I see the your OS is Chinese version windows. Do you think that may matter the column/font?

I use Chinese WinXP pro. And what’s your OS version? I will check this issue in an English Win2000.

I think it's a problem of zoom factor. Please change the zoom factor from 65% to 100%. You will see all work fine.

Actually in my machine, whether 65% or 100% is fine.

if both 65 and 100 work on your pc, it should work on mine as well. we are using win2000 english version.

thank you

Is that possible that u can send this excel sheet to some other aspose team that are not running Chinese version windows? The size of the font in Chinese version looks like lil bit narrower than normal font. thank you