WorkSheet.AutoFitColumns issue with italic text

After updating to version Aspose Cells 7.3.1.0 I found an issue with WorkSheet.AutoFitColumns() if the sheet contains italic text.

It seems that the calculation for a cell’s required width doesn’t account for italic text (which is wider than normal text). So if the italic cell is the widest cell in the column, the calculated width will be sufficient for normal text, but not for italic text (showing as ######).

Bold text seems to work fine.

Please check the attached excel file for the result.

Hi,

Please make sure that you have all the fonts in your Environment installed used by cells in your Excel file. You may set the FontDir to make cells can find them for auto-fit operation. As simple test, please copy all needed fonts to your environment and use such as CellsHelper.SetFontDir() to make cells use them, then check whether it works fine now.
Also, try our latest version/fix: Aspose.Cells for .NET v7.3.1.4

Hi Amjad,

I am using plain old Arial, so the font should be found (and I didn’t have this problem with an older version of Aspose cells).

Nevertheless I added CellsHelper.FontDir (instead of SetFontDir()) to my project.
I also used the version 7.3.1.4 you sent.

Still the same result.

Hi,


We have logged an investigative ticket with an id: CELLSNET-41063 for your issue. We will soon look into it to figure it out.

By the way, which older version of the product is working with it. Also, it would be great if you could provide us a simpler console application (please zip it prior attaching here) to post it here, it will help us really to fix your issue more accurately.

Thank you.

The version that worked as expected was an ancient one: 4.8.0.0.

Here is some example C# code to demonstrate the problem:

var theWorkbook = new Workbook();
Worksheet theSheet = theWorkbook.Worksheets.Add(“test”);
theSheet.Cells[“A1”].PutValue(100000);
theSheet.Cells[“A2”].PutValue(50000);
theSheet.Cells[“A3”].PutValue(150000);

Style theItalicStyle = theWorkbook.Styles[theWorkbook.Styles.Add()];
theItalicStyle.Font.IsItalic = true;
theSheet.Cells[“A3”].SetStyle(theItalicStyle);

Style theCurrencyStyle = theWorkbook.Styles[theWorkbook.Styles.Add()];
theCurrencyStyle.Number = 6;
theSheet.Cells.Columns[0].ApplyStyle(theCurrencyStyle, new StyleFlag {NumberFormat = true});

theSheet.AutoFitRows();
theSheet.AutoFitColumns();

theWorkbook.Save(“test.xls”);

Hi,

Thanks for your sample code and using Aspose.Cells.

I have tried your code with the latest version:
Aspose.Cells
for .NET v7.3.1.4

but I could not replicate it.

I have attached the output xls file generated by your code for your reference.

Also, I have logged your comments in our database against the issue id: CELLSNET-41063

We will look into your issue and update you asap.

Then it must be something about the excel version I’m using in combination with the new Aspose Cells version.

I have Excel 2000 here (Dutch), when opening the sheet you attached I see the same as when I produce the sheet myself: Cell A3 is not wide enough to show its contents.

So to wrap it up:
- Excel 2000 with old Aspose Cells: issue wasn’t there.
- Excel 2000 with new Aspose Cells: issue appeared.
- Your version of Excel with new Aspose Cells: issue cannot be reproduced.

I’ll try opening the sheet with other versions of Excel to find out more.

Hi,


Thanks for your further feedback.

I have logged the information to attach with your issue into our database. We will look into it soon.
I have so far tested your code and opened the output file into English Excel versions i.e. Excel 2003, 2007 and 2010. We will continue to test it on Dutch version(s) of Excel.

Thank you.

I have only been able to test with Word 2010, English and Dutch. Sheet looked fine there as you had noticed as well.

Hi,


Could you attach some screen shots to show the issue for your Excel version or environment. It will help us to investigate the issue more accurately.

Thank you.

Sure,

Here are two screenshots.

- CELLSNET-41063-1.png is a screenshot of what the test.xls (attached in an earlier message) sheet looks like when I open it with Excel 2000 dutch, with the original width that is not enough for my excel version.
- CELLSNET-41063-2.png is a screenshot showing the adjusted width after clicking ‘autowidth’ (clicking in the header between column A and B).

As you can see, the width changed from 8.71 to 9.57. Apperently 8.71 is enough for other Excel versions, but not for my old Excel 2000.

Hi,


Thanks for providing us the screen shots for your Dutch Excel 2000. It may help us to figure out your issue. We have logged it against your issue in our database.

We will analyze your issue soon. Once we have any update on it, we will let you know here.

Thank you.