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

Free Support Forum - aspose.com

Excel is not properly converted to image

i am converting Excel to image like this
Worksheet ws = this.xslDocument.Worksheets[0];
ImageOrPrintOptions iop = new ImageOrPrintOptions();
iop.OnePagePerSheet = true;
iop.IsCellAutoFit = true;

iop.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
SheetRender wr = new SheetRender(ws, iop);

wr.ToImage(0, pathToImage);

the problem is that if big Excel doc is used with many rows or columns the text on the output image is completely unreadable, because image size is too small. (i attached the Excel file i am using and image produced) I can workaround the issue if i explicitly set bigger resolution

iop.HorizontalResolution = 250;
iop.VerticalResolution =250;

then image is produced of bigger size and text is readible. But i do not know in advance how big is the the Excel file, setting big resolution for a small file will produce image with huge text size.

How can avoid setting explicitely resolution and have satisfactory results for all Excel docs of any size?


Well, if you could open your template File into MS Excel and take the print preview, you will see that view is similar to your output image. You have set Fit to pages tall/wide option, so you are getting one page with too small contents on it. I think for your requirement you should use Scaling factor accordingly before taking image of the sheet. But mind you doing so, it might give you more than 1 pages as output.


//Setting the scaling factor to 72

ws.PageSetup.Zoom = 72;

See the topic for reference: