Free Support Forum - aspose.com

For some workbooks SheetRender returns Object reference not set to an instance of an object

I am using Aspose.Cells .Net to convert an Excel worksheet into a PNG. For many workbooks it works OK, but for some I get “Object reference not set to an instance of an object.” when trying to produce a bitmap.
Commands are:
xlBook = New Workbook(sFName)
Dim opts As ImageOrPrintOptions = New ImageOrPrintOptions
opts.ImageType = Aspose.Cells.Drawing.ImageType.Png
Dim ws As Worksheet = xlBook.Worksheets(0)
Dim sr As SheetRender = New SheetRender(ws, opts)
Dim bitmap As Bitmap = sr.ToImage(1)
bitmap.Save(sFileSrvPath & sImgOutFName)

The error occurs on bitmap.Save. Thanks for your help!

Oh, hang on. Just figured out it’s the sr.ToImage(1). It should be sr.ToImage(0). Sorry for the false alarm and thanks.

@rdaviessci,
Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.