Bad height calculated by AutoFitRows function

Hello,

It seems that calculation of height with AutoFitRows function is bugged when cells value is only composed by numeric values --> part of values are not displayed.

Please find the template and the produced files in attached zip.

Our implementation:

Dim szFile As String = “C:\Temp\file.xlsx”
Dim szFilePdf As String = szFile + “.pdf”
Dim wb As Aspose.Cells.Workbook = Nothing
Dim sb As Aspose.Cells.Worksheet = Nothing
Dim options As Aspose.Cells.AutoFitterOptions = New Aspose.Cells.AutoFitterOptions

    options.AutoFitMergedCells = True
    wb = New Aspose.Cells.Workbook(szFile)
    sb = wb.Worksheets(0)
    sb.Cells(6, 3).Value = "415 416 417 418"       ' TEST file1.xlsx.pdf
    'sb.Cells(6, 3).Value = "!415 !416 !417 !418"        ' TEST file2.xlsx.pdf
    sb.AutoFitRows(6, 6, options)
    wb.Save(szFilePdf, Aspose.Cells.SaveFormat.Pdf)

Thanks for your help.

Test.zip (72.7 KB)

@LaurentToulouse,

Thanks for providing us template file, sample code and details.

Well, you need to set/adjust column’ width accordingly first for your part of data to be shown line by line in the cell. You can add a line to your code, it will work fine:
e.g
Sample code:

Dim szFile As String = "C:\Temp\file.xlsx"
Dim szFilePdf As String = szFile + ".pdf"
Dim wb As Aspose.Cells.Workbook = Nothing
Dim sb As Aspose.Cells.Worksheet = Nothing
Dim options As Aspose.Cells.AutoFitterOptions = New Aspose.Cells.AutoFitterOptions

    options.AutoFitMergedCells = True
    wb = New Aspose.Cells.Workbook(szFile)
    sb = wb.Worksheets(0)

sb.Cells.SetColumnWidthPixel(3,44)
sb.Cells(6, 3).Value = “415 416 417 418” ’ TEST file1.xlsx.pdf
'sb.Cells(6, 3).Value = “!415 !416 !417 !418” ’ TEST file2.xlsx.pdf
sb.AutoFitRows(6, 6, options)
wb.Save(szFilePdf, Aspose.Cells.SaveFormat.Pdf)

Hope, this helps a bit.

Hi Amjad_Sahi,

We don’t want to define manually a width for column, as we don’t know the content that will be injected in the cells. Sometimes it’s a large text, sometimes it’s a list of numeric values.

What I don’t understand is : why it works fine with alphanumeric values, but not with numeric values?

@LaurentToulouse,

As we already observed the issue as you mentioned by using your sample code with template file. Moreover, the workaround does not suit your needs. We found incorrect height is calculated by AutoFitRows function when there are numeric values in the cell(s), it works fine when there are alphanumeric value(s). I have logged a ticket with an id “CELLSNET-45718” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

@LaurentToulouse,

If you save the output to XLSX file, and then manually autofit row height in Microsoft Excel, you will find our autofit row height is right.
The problem is while rendering to PDF, we render Cell D7 to four lines:
415
416
417
418
but Microsoft Excel render Cell D7 to two lines in printview:
415 416
417 418

Currently we cannot find a way to fix the problem. If we fix it in the future, we will let you know.