Row height by export to PDF

Hi all,

When I have code like this:

    var excelFile = new ExcelFile();
    var sheet = excelFile.Worksheets.Add("Sheet1");
    for (int row = 0; row < 70; row++)
    {
        sheet.Cells[row, 0].Value = row;
    }
    excelFile.Save(@"d:\temp\test.xlsx");

    var pdfOptions = new PdfSaveOptions();
    pdfOptions.SelectionType = SelectionType.EntireFile;
    excelFile.Save(@"d:\temp\test.pdf", pdfOptions);

As result, I get 53 rows on the first page in the PDF file.

If I open the same PDF in Excel and exports it as PDF I get 49 rows.

Surprisingly if I just explicitly set row height to the same value like:

var excelRow = excelFile.Worksheets[0].Rows[row];
excelRow.Height = (int)(excelRow.Height * 1);

I get 56 rows from Gembox 58 rows from Excel.

Any idea, why this is happening and what is actually the correct result?

Thanks a lot for the help

Ota

Hi,

GemBox.Spreadsheet does not use Microsoft Excel to calculate positions and sizes of elements on the page, therefore the results might not be identical since the Excel’s layout/rendering engine is not standardized nor its code is open.

GemBox.Spreadsheet, just like any other Excel application, uses its own layout/rendering engine to paginate and render the spreadsheet’s content. We do not have Excel’s rendering engine source code, no one does, but we do try to provide the exact calculations as much as possible.

However, again I’m afraid that some differences may occur. Also, the differences may occur with other Excel applications as well like OpenOffice Calc, LibreOffice Calc, Microsoft Excel for Mac, etc.
For instance, if you export that “test.xlsx” file to PDF with LibreOffice Calc you’ll get 56 rows.

Anyway, perhaps you should consider explicitly specifying horizontal and vertical page breaks? That way you would define exactly where you want the page breaks to occur.

Regards,
Mario