I have attached the file.
private PageListResult ConvertExcelToImage()
{
try
{
var pageResultList = new List();
// Instantiate the License class
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Total.lic");
var pageImgDir = CreateTempDirectory();
// Convert .xls and .xlsx file to PDF.
Workbook book = new Workbook(this._stream);
//Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions()
{
ImageFormat = ImageFormat.Png, //Specify the image format
VerticalResolution = this.config.ImageReadDpi,
HorizontalResolution = this.config.ImageReadDpi
};
int totalPageCount = 0;
foreach (Worksheet sheet in book.Worksheets)
{
//Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
for (int i = 0; i < sr.PageCount; i++)
{
totalPageCount++;
if (totalPageCount > this.config.DocumentMaxPageNumber)
break;
using (Bitmap bitmap = sr.ToImage(i))
{
var imgPath = ExportImageFile(pageImgDir, totalPageCount, bitmap);
var thumbPath = ExportThumbnailFile(imgPath, totalPageCount, bitmap);
var pageResult = new PageResult(totalPageCount, imgPath, thumbPath);
pageResultList.Add(pageResult);
}
}
if (totalPageCount >= this.config.DocumentMaxPageNumber) break;
}
return new PageListResult(pageResultList, this.config.DocumentMaxPageNumber < totalPageCount);
}
catch (Exception ex)
{
throw new Exception("Failure converting excel", ex);
}
}