AutoFitRow method in Worksheet not working as expected: Aspose.Cells Version 8.6.2.0

Rows 17 through 22 were executed by the statement below. Where levelCount = 3, productCount = 6 and costStartRow = 16. But the row height did not get adjusted to show all content. Please see the attached xlsx and pdf files.



for (int i = 0; i
{

workbook.Worksheets[“Level” + levelCount].AutoFitRow(costStartRow + i);

}

Hi,

Thanks for your posting and using Aspose.Cells.

We have tested this issue with the following sample code using the latest version

Aspose.Cells
for .NET v8.6.3.5
and found it is working fine and generating the correct pdf. We have attached the output pdf for your reference.

Please use the latest version and if your problem still occurs then please provide us your sample console application replicating this issue. We will look into it and help you asap.

C#

string filePath = @“D:\Downloads\Menu_999999_ZZZZZZ_NDC_20160121141315815.xlsx”;

Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.Worksheets[“Level3”];

worksheet.AutoFitRow(16);
worksheet.AutoFitRow(17);
worksheet.AutoFitRow(18);
worksheet.AutoFitRow(19);
worksheet.AutoFitRow(20);
worksheet.AutoFitRow(21);

workbook.Save(filePath + “.out.pdf”);

Hi,

I used the version 8.63.5 and still could not get the method AutoFitRow work.

Please advise.

JS Huang

Hi,

Thanks for your posting and using Aspose.Cells.

Please provide us your console application project replicating this issue. We will look into it and help you asap.

Hi,



I have the console application zipped as AutoFifRowConsole.zip. The file Menu.xlsx is used as input. The resulting pdf output looks correct with the row height adjusted to fit the content. The resulting xlss file does not have the row height adjusted.



This pdf result is different from what I obtained from another similar application.



Please advise on how to have the row height adjusted in xlsx file.



Thanks,

Hi,

Thanks for your simplified console application and using Aspose.Cells.

We were able to observe this issue after executing your console application and found that issue exists in the resultant excel file and not in the output pdf.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-44186 - AutoFitRow method in Worksheet is not working as expected

Below is the sample code I have used for testing and I have also attached the output excel file and the output pdf file as well as the screenshot highlighting this issue for a reference.

C#
string filePath = @“D:\Downloads\Menu.xlsx”;

LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
Workbook workbook = new Workbook(filePath, loadOptions);

for (int i = 16; i < 22; i++)
{
workbook.Worksheets[“Level3”].AutoFitRow(i);
}

workbook.CalculateFormula();

workbook.Save(filePath + “.out.xlsx”, SaveFormat.Xlsx);
workbook.Save(filePath + “.out.pdf”, SaveFormat.Pdf);

Hi,

Thanks for using Aspose.Cells.

Please change your sample code like this and use AutoFitterOptions.AutoFitMergedCells property and set it to true, then your excel file output will be correct. I have attached the output excel file for your reference.

C#

string filePath = @“D:\Downloads\Menu.xlsx”;

LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
Workbook workbook = new Workbook(filePath, loadOptions);

AutoFitterOptions opts = new AutoFitterOptions();
opts.AutoFitMergedCells = true;

for (int i = 16; i < 22; i++)
{
workbook.Worksheets[“Level3”].AutoFitRow(i, 0, 100, opts);
}

workbook.CalculateFormula();

workbook.Save(filePath + “.out.xlsx”, SaveFormat.Xlsx);
workbook.Save(filePath + “.out.pdf”, SaveFormat.Pdf);