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 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,
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,
I have only been able to test with Word 2010, English and Dutch. Sheet looked fine there as you had noticed as well.
Hi,
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,