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

Free Support Forum - aspose.com

Issue with SheetRender's ToImage function

Hi Team,

We have used the following code for creating images out of worksheet:

string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

Workbook book = new Workbook(dataDir+ “TestData.xlsx”);
Worksheet sheet = book.Worksheets[0];
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.HorizontalResolution = 200;
options.VerticalResolution = 200;
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;

// Sheet2Image By Page conversion
SheetRender sr = new SheetRender(sheet, options);
for (int j = 0; j < sr.PageCount; j++)
sr.ToImage(j, dataDir+ “test” + sheet.Name + " Page" + (j + 1) + “.out.tif”);

However it is working fine in Visual studio at the time of development, but after deploying it on QA server, it is not behaving correctly.
Sometimes it creates the images and sometimes it is throwing the following exception for the same excel sheet:

Aspose.Cells.CellsException: Parameter is not valid. at .(Int32 , ImageOrPrintOptions ) at .(Int32 , ImageOrPrintOptions , Stream ) at .(Int32 , String , ImageOrPrintOptions ) at Aspose.Cells.Rendering.SheetRender.ToImage(Int32 pageIndex, String fileName)

Product version id for aspose.cells.dll is

Please help asap as we are stuck here.


Thanks for providing sample code and details.

Well, it looks odd as sometimes it works and sometimes it does not work. If it works fine in your development machine, it should equally work fine on other locations. I guess, you are running your application (on QA server) in medium trust. Aspose.Cells works fine in full trust only. Could you please check the trust level and if it is medium then change it to full and see if it resolves your issue. Please also see the following documentation article that explains the trust levels for Aspose.Cells:

Thank you.

Hi Amjad,

Thanks for your quick response.

We are running our application in full trust mode only.
In addition to that, we are setting the license file like this :

License license = new License();

Please check if this is the correct way of setting it.



Thanks for your confirmation on full trust level.

We are very sorry but we cannot evaluate your issue unless we could reproduce it on our end. We recommend you to kindly try our latest version/fix: Aspose.Cells for .NET v17.6 (your existing subscription might not allow you to use it, you may try it in evaluation mode though). If you still find the issue with v17.6, kindly do create a simple console application (runnable), zip it and post us here to reproduce the issue on our end, we will check it soon.

Thank you.