We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

SheetRender - reports different page size for A4


We’re currently having an issue with the way SheetRender is rendering ranges to image. Seems that the size of the output image differs when run on different systems:
Here is the code used to reproduce the issue:

            var workbook = new Workbook(@“Image.xlsx”);
        <span style="color:blue;">var</span> imageOptions = <span style="color:blue;">new</span> <span style="color:#2b91af;">ImageOrPrintOptions</span>
                                   Quality = 100,
                                   VerticalResolution = 200,
                                   HorizontalResolution = 200,
                                   PrintingPage = <span style="color:#2b91af;">PrintingPageType</span>.IgnoreBlank,
                                   ImageFormat = <span style="color:#2b91af;">ImageFormat</span>.Png,
                                   OnePagePerSheet = <span style="color:blue;">true</span>

        <span style="color:blue;">var</span> worksheet = workbook.Worksheets[0];

        <span style="color:blue;">string</span> printArea = <span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"b2:k24"</span>);
        worksheet.PageSetup.PrintArea = printArea;
        worksheet.PageSetup.TopMargin = 0;
        worksheet.PageSetup.LeftMargin = 0;
        worksheet.PageSetup.RightMargin = 0;
        worksheet.PageSetup.BottomMargin = 0;

        <span style="color:blue;">var</span> sheetRender = <span style="color:blue;">new</span> <span style="color:#2b91af;">SheetRender</span>(worksheet, imageOptions);

        <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"PageSize: </span><span style="color:mediumseagreen;">{0}</span><span style="color:#a31515;">"</span>, worksheet.PageSetup.PaperSize);
        <span style="color:blue;">var</span> size = sheetRender.GetPageSize(0);
        <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"Page size: Width:</span><span style="color:mediumseagreen;">{0}</span><span style="color:#a31515;">, Height:</span><span style="color:mediumseagreen;">{1}</span><span style="color:#a31515;">"</span>, size.Width, size.Height);

        sheetRender.ToImage(0, <span style="color:#a31515;">@"out.png"</span>);</pre>After running the above code on different systems with different Windows versions will notice that the page size is reported differently, also the output image has different size:<br><br>Windows Server 2003, x86/x64<br>PageSize: PaperA4<br>Page size: Width:1607, Height:928<br><br>Windows Server 2008 R2, x64<br>PageSize: PaperA4<br>Page size: Width:1406, Height:928<br><br>Windows 7, x64<br>PageSize: PaperA4<br>Page size: Width:1406, Height:928<br><br>Thank you,<br>Bogdan Rusu,<br>IBM Romania.<br><br>


Thanks for your reporting and using Aspose.Cells for .NET.

We have logged your issue in our database for investigation. We will look into this issue and get back to you with our findings.

Also, we might need some additional information at your end. In that case, we will update you here by posting on this thread.

Once there is some update for you relating to this issue, we will let you know asap.

This issue has been logged as CELLSNET-40994.


Thank you for investigating this issue, we are waiting for a solution. Fell free to ask for additional information from our side.

Bogdan Rusu,
IBM Romania.


Thanks for using Aspose.Cells.

You are welcome. We have checked your issue status in our database.

At the moment, there is no update for you. We will keep you updated about this issue.

Meanwhile, if you face any other issue relating to Aspose.Cells, please let us know, we will be glad to assist you further.


Do you have any updates on this old issue, or an estimate when this will be done ?

Thank you,
Mihai Andrei
Sr Software Engineer
IBM Romania

Hi Mihai,

Thanks for your posting and using Aspose.Cells.

It does not seem to be a paper size issue but it seems to be an image size issue.

I have generated the image on Windows XP and its image size is 1414x927 with the latest version: Aspose.Cells
for .NET v8.1.0.1
. I have attached the output image for a reference.

Could you please provide all the images of your machines so that we could investigate this issue further?

Do you need to know why image size differs on different machines?


Please use our original post, I believe it’s quite detailed and well explained; with that code you can obtain the different images with diferrent sizes, as obtained by using SheetRender.

Yes, we need to know why the images are rendered with different sizes on different systems, since the Paper Size is the same - A4 (as per worksheet.PageSetup.PaperSize).

Thank you,
Mihai Andrei

Hi Mihai,

Thanks for your posting and using Aspose.Cells.

I have also run your code in Windows 7-64 bit machine and I got the same result. The image size is same as Windows XP image size. Both are 1414x927.

I have attached the image and screenshot for your reference.

Kindly download and use the latest version: Aspose.Cells
for .NET v8.1.0.1
and see how things go at your end. Your issue should be fixed with it.


Thanks for using Aspose.Cells.

1. Because OnePagePerSheet to set to true, the output page size is decided by content width and height. The page size setting in PageSetup will not take effect.

2. For different output page size on different systems, two factors may cause this:
a. The default font of workbook "Image.xlsx" is "Calibri". Please make sure the font is installed on different systems. If default font is not installed, the column width will not right.
b. Different display settings(e.g. 100%, 125%...), this will cause different DPI and different column width.