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

Free Support Forum - aspose.com

SheetToImage in newer version of aspose.cells


Currently we are facing issue with where aspose throws error:
<span style=“font-size:10.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Error in Render document of
type SpreadSheet Detail Fault :Aspose.Cells.CellsException: There are too much
formats in the worksheet bei Aspose.Cells.Workbook.Save
<span style=“font-size:10.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:navy;mso-ansi-language:EN-US;
Based on older post in aspose forum figured out that this has been fixed in version 7.0.2.

But noticed a comment over there saying
We are happy to announce Aspose.Cells for .NET v7.0.2! In this version, we made several enhancements and fixed number of user issues/bugs. Moreover, we have removed some unnecessary older obsolete methods for Sheet-to-Image feature now.

In our application we make use of the method called SheetToImage. Could you please let me know if this method was deprecated in the newer version by another method for a better approach. If so could you please pass on the details.

In any case please let me know how can I upgrade to newer version of aspose.cells & still use the feature of SheetToImage functionality.



Please see the following code how to use the replacement of sheet2image feature.


string path = @“F:\ooxmlPackage2.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;

options.ImageFormat = ImageFormat.Emf;

SheetRender sr = new SheetRender(worksheet, options);

Bitmap bitmap = sr.ToImage(0);

bitmap.Save(path + “.out.emf”, ImageFormat.Emf);


Also, we recommend you to kindly see the document/article(s):

Thank you.


I have replaced to use the new Function but now the image fails to even appear(gives error on print preview margins do not fit page size). Can you please go through the attached code and see the difference. I am basically adding footer image. I suppose you will have to do a print preview to check the issue in the output files.



Thanks for the sample project.

I can notice the issue in the output file by using latest version/fix v7.1.2.1. When I opened the generated file into MS Excel and try to take the print preview of the first sheet, I got error (regarding page margins… Error: “Margin do not fit page size”) in MS Excel.

I have logged a ticket with an id: CELLSNET-40493. We will look into it soon.

Thank you.


Well, after further investigation, it is not an issue but a bit changed model in the new versions. You need to set OnePagePerSheet option to “true”, so you may add a line to your code, it works fine.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aspose.Cells;
using Aspose.Cells.Rendering;
using System.IO;

namespace AsposeTester
class Program
static void Main(string[] args)
Workbook _oAsposeWorkbook = new Workbook("…/…/…/AsposeTestFile/AsposeTester.xlsx");
Worksheet _oAsposeWorksheet = _oAsposeWorkbook.Worksheets[0];

Worksheet Footer = _oAsposeWorkbook.Worksheets[“Footer”];
Footer.PageSetup.FooterMargin = 0;
Footer.PageSetup.BottomMargin = 0;
Footer.PageSetup.LeftMargin = 0;
Footer.PageSetup.RightMargin = 0;
Footer.PageSetup.TopMargin = 0;
Footer.PageSetup.HeaderMargin = 0;

ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 800;
options.VerticalResolution = 600;
options.TiffCompression = TiffCompression.CompressionLZW;
options.IsCellAutoFit = true;
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
options.PrintingPage = PrintingPageType.Default;
options.OnePagePerSheet = true;
SheetRender sr = new SheetRender(Footer, options);
System.Drawing.Bitmap img = sr.ToImage(0);
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
//((Worksheet)oSheet).PageSetup.FooterMargin = 0;
((Worksheet)_oAsposeWorksheet).PageSetup.BottomMarginInch = (Convert.ToDouble(img.Height) / img.VerticalResolution) + 0.2;
((Worksheet)_oAsposeWorksheet).PageSetup.FooterMargin = Convert.ToDouble(img.Height) / img.VerticalResolution;
((Worksheet)_oAsposeWorksheet).PageSetup.SetFooterPicture(1, ms.ToArray());
((Worksheet)_oAsposeWorksheet).PageSetup.SetFooter(1, “&G”);



Thanks the solution works.



Good to know that your issue is resolved now.

Thank you.