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.

Hi,

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

Workbook wb = new Workbook();
wb.Open(@“F:\test\margin\AsposeTest\AsposeTest\bin\Debug\Book1.xls”);
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.Save(@“F:\test\margin\AsposeTest\AsposeTest\bin\Debug\SheetToImagen.bmp”);
Bitmap[] bitMaps = ws.SheetToImageByPage();
bitMaps[0].Save(@“F:\test\margin\AsposeTest\AsposeTest\bin\Debug\SheetToImageByPagen.bmp”);


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.

Hi,

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.

Hi,

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.

Hi,

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.