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

Free Support Forum - aspose.com

Worksheet.SheetToImageByPage leaves whitespace around image even when margins are set to zero

When I use WorkSheet.SheetToImage and set left, right, top and bottom margins all equal to zero, there is no whitespace around the image. However, when I use WorkSheet.SheetToImageByPage, I always get white space around the image regardless of what the margins are set to. Attached is some example code.


Please try to change your code as following, hopefully it will fit your need.

Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];

ws.PageSetup.CenterHorizontally = false;
ws.PageSetup.CenterVertically = false;

ws.PageSetup.LeftMargin = 0;
ws.PageSetup.RightMargin = 0;
ws.PageSetup.TopMargin = 0;
ws.PageSetup.BottomMargin = 0;
Bitmap bitMap = ws.SheetToImage();
Bitmap[] bitMaps = ws.SheetToImageByPage();

Thank you.

This doesn’t solve the issue. I need the image of the worksheet without any white space around it. The work around you suggested just moves the worksheet image to the left upper right with all the white space on the right and lower part of the image.


Well, this is how the SheetToImageByPage method works. If you need to fetch only data without white space around it, you should use SheetToImage method instead. Actually the SheetToImageByPage method renders the images based on the default page settings. Anyways, we need to check and analyze if the SheetToImage method should support in other way or not. We will get back to you soon.

Thank you.


We have added your feature request to log into our issue tracking system with an issue id: CELLSNET-12630. We will be on it soon. We might add a property for ImageOrPrintOption to control/implement your desired results for SheetToImageByPage method.

Thank you.

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p>


Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have added IsImageFitToPage property to ImageOrPrintOptions as per your requirement.

Thank You & Best Regards,

The issues you have found earlier (filed as 12630) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.