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

Free Support Forum - aspose.com

Exception on workbook.Worksheets[0].SheetToImage(false- options)

Hi,


I use the Aspose.Cells component,when I use the method SheetToImage like that:
Bitmap bitmap =workbook.Worksheets[0].SheetToImage(false, options);

It throws exception when the worksheet’s content is very big. How can I modify it?

(when the worksheet’​s content is not very big,It can be converted to image correct. wh​en it’s very big,It WILL THROW EXCEPTIONS​)

Code:

public void ShowMapInBrowser(int curOrgID, int selYear, int type)
{
HttpResponse response = HttpContext.Current.Response;

this.MapType = type;
this.IsExport = false;
Workbook workbook = new Workbook();
switch (type)
{
case 1:
workbook = this.GetEquityMapWorkBook(curOrgID, selYear);
break;
case 2:
workbook = this.GetManagementOrgMapWorkBook(curOrgID, selYear);
break;
default:
break;
}

this.IsExport = false;
workbook.Worksheets[0].PageSetup.FitToPagesTall =5;
workbook.Worksheets[0].PageSetup.FitToPagesWide = 5;

ImageOrPrintOptions options = new ImageOrPrintOptions();
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
options.VerticalResolution = 240;
options.HorizontalResolution = 240;
options.TiffCompression = TiffCompression.CompressionNone;
// options.PrintingPage = PrintingPageType.Default;
options.IsCellAutoFit = false;
options.PrintingPage = PrintingPageType.IgnoreBlank;
options.Quality = 1;
Bitmap bitmap = workbook.Worksheets[0].SheetToImage(false, options);//Throw exception here.

MemoryStream stream = new MemoryStream();


bitmap.Save(stream, ImageFormat.Png);
response.BinaryWrite(stream.ToArray());
response.End();
bitmap.Dispose();
}



Aspose.Cells for .NET v4.8.1.0, .NET Framework 4.0

Thanks

This message was posted using Email2Forum by babar.raza.

Hi,

You are using very old version of Aspose.Cells for .NET.

Please download and try the latest version:
Aspose.Cells
for .NET v7.0.4.6

and let us know if it works fine.

Thank you.Is the verson:7.0.4.6 has the method SheetToImage()? Is there other method to replace this method?

Hi,

Here is the simplest code you can use to test conversion of your worsheet using the latest version into png format or you can modify it for your needs.

C#



string path = @“F:\Shak-Data-RW\Downloads\Aspose+Render+Input+1.xlsx”;

Workbook workbook = new Workbook(path);


Worksheet worksheet = workbook.Worksheets[0];


//Apply different Image / Print options.

Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();

options.OnePagePerSheet = true;


SheetRender sr = new SheetRender(worksheet, options);


Bitmap bitmap = sr.ToImage(0);


bitmap.Save(path + “.out.png”, ImageFormat.Png);

Thanks! I’ll try it right now.

Hi,

We recommend you to kindly try latest version v7.1.0 :
http://www.aspose.com/community/files/51/.net-components/aspose.cells-for-.net/entry355234.aspx