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

Free Support Forum - aspose.com

White space in generated image caused by enviroment

Hello, we are trying to get images from excel tables. Bellow is the code we are using and I’ve uploaded the input & output data. The problem is that the generated picture contains a lot of white space!

I’ve applied the instructions to remove white space as you can see below but no luck.

Furthermore it works on other machines except for my own. I am the only one who upgraded to Windows 10 (1809) and on Windows 7 and deployment server this does not occur (I published my code base). I installed the latest version of Cells (19.11.0).

The question is: what difference in environment could be causing the white space? And what could we do to prevent this in the future when everything will be migrated?

private static void NewMethod(string printArea = null)
            new Aspose.Cells.License().SetLicense(@"...");

           Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(@"... template.xlsx");
            Aspose.Cells.Worksheet AsposeSheet = wb.Worksheets[0];

            Aspose.Cells.PageSetup pageSetup = AsposeSheet.PageSetup;
            pageSetup.PrintArea = new SheetNameWithPrintArea("kpi summary table", "A1:G6").PrintArea;
            pageSetup.RightMargin = pageSetup.BottomMargin = pageSetup.LeftMargin = pageSetup.TopMargin = 0;
            var stream = new System.IO.MemoryStream();
            new Aspose.Cells.Rendering.SheetRender(AsposeSheet, IMAGE_OR_PRINT_OPTIONS).ToImage(0, stream);

            var file = new System.IO.FileStream(@"... picture.emf", System.IO.FileMode.Create);

            stream.Position = 0;
            file.Position = 0;

        public static Aspose.Cells.Rendering.ImageOrPrintOptions IMAGE_OR_PRINT_OPTIONS
                return new Aspose.Cells.Rendering.ImageOrPrintOptions
                    SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,
                    EmfType = System.Drawing.Imaging.EmfType.EmfPlusDual,
                    ImageType = Aspose.Cells.Drawing.ImageType.Emf,
                    PrintingPage = Aspose.Cells.PrintingPageType.IgnoreBlank,
                    IsCellAutoFit = true,
                    OnePagePerSheet = true,


Thanks for the code segment and details.

We do not find your attached files (e.g Template file and image file, etc.). Please zip the files and attach it here. Also, there seems some objects or other members in your code segment for which we are not sure, so we appreciate if you could create a sample console demo application (runnable), zip the project and provide us here, we will check it soon. You may exclude Aspose.Cells.dll in your attach project to minimize its size.

PS. What is the display settings on your machine (Windows 10 (1809))? Please note, the display settings should be 100% when you perform operations like Sheet to image, Excel to PDF rendering, etc.

It seems the display setting was the issue. You might want to consider adding it to the documentation: https://docs.aspose.com/display/cellsnet/Worksheet+to+Image+-+Remove+Whitespace+around+Data


Good to know that your issue is sorted out now.
And, thanks for your suggestion. We will soon add a note to the document and in other relevant docs.