Hi,
I am working for Microsoft and we hold a valid Aspose.Total .NET platform license. I am working on a tool that is supposed to convert first sheet of each excel file into a .bmp image. I am using the below code snippet to achieve this.
//initializing Aspose license for Excel Application
AsposeExcel.License license = new AsposeExcel.License();
license.SetLicense("Aspose.Total.lic");
//initializing Aspose Excel Workbook object with the provided excel template.
AsposeExcel.Workbook workBook = new AsposeExcel.Workbook(sourcePath);
//fetch file name of excel template without extension i.e. asset id
fileName = Path.GetFileNameWithoutExtension(workBook.FileName);
//define the temporary image format.
imageFileExtension = ".bmp";
//initializing image saving options and defining the image format.
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;
options.OnePagePerSheet = false;
//initializing sheet render object with first sheet in the workbook
Aspose.Cells.Rendering.SheetRender renderImage = new Aspose.Cells.Rendering.SheetRender(workBook.Worksheets[0], options);
//looping through all the pages in the first sheet.
for (int i = 0; i < renderImage.PageCount; i++)
{
renderImage.PageCount = 1;
//creating the temporary bmp file in the temp folder
renderImage.ToImage(i, tempFolderPath + @"\" + fileName + "_Bmp" + ++imgCounter + imageFileExtension);
}//initializing Aspose license for Excel Application
AsposeExcel.License license = new AsposeExcel.License();
license.SetLicense("Aspose.Total.lic");
//initializing Aspose Excel Workbook object with the provided excel template.
AsposeExcel.Workbook workBook = new AsposeExcel.Workbook(sourcePath);
//fetch file name of excel template without extension i.e. asset id
fileName = Path.GetFileNameWithoutExtension(workBook.FileName);
//define the temporary image format.
imageFileExtension = ".bmp";
//initializing image saving options and defining the image format.
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Bmp;
options.OnePagePerSheet = false;
//initializing sheet render object with first sheet in the workbook
Aspose.Cells.Rendering.SheetRender renderImage = new Aspose.Cells.Rendering.SheetRender(workBook.Worksheets[0], options);
//looping through all the pages in the first sheet.
for (int i = 0; i < renderImage.PageCount; i++)
{
renderImage.PageCount = 1;
//creating the temporary bmp file in the temp folder
renderImage.ToImage(i, tempFolderPath + @"\" + fileName + "_Bmp" + ++imgCounter + imageFileExtension);
}
Last line renderImage.ToImage throws an Out Of memory exception. Could you please help here as soon as possible as this is a production critical tool and I can't spend much time debugging and finding out the root cause. Attached is the sample excel file for which it fails to render image.