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

Free Support Forum - aspose.com

Problems with excel file

Hi, we experiencing a big problem with excel files (attached here)
The file result more than 8000 pages when converting to png images and more than 32000 pages converting in PDF.
Result in site production is web server crash.
Some Advice or update to avoid this problem? maybe consideration about number of columns?

can we apply some other consideration when using excel files?
here’s the code we use to export file in images (a loop for every worksheet and for every sheet page count) and pdf export:

for (int i = 0; i < ((Aspose.Cells.Workbook)m_oDocument).Worksheets.Count; i++)
{
Aspose.Cells.Rendering.SheetRender oSheet = new Aspose.Cells.Rendering.SheetRender(((Aspose.Cells.Workbook)m_oDocument).Worksheets[i], OptionsC);
iTotalPagesCount += oSheet.PageCount;
if (_iPageIndex < iTotalPagesCount)
{
oSheet.ToImage(_iPageIndex - iSheetsPagesCount, _oOutputStream);
break;
}
iSheetsPagesCount = iTotalPagesCount;
}



Aspose.Cells.PdfSaveOptions OptionsC = new Aspose.Cells.PdfSaveOptions();
OptionsC.AllColumnsInOnePagePerSheet = true;
((Aspose.Cells.Workbook)m_oDocument).Save(_oOutputStream, OptionsC);


thank’s a lot

Hi Valerio,


First of all, please accept our sincere apologies for a bit delayed response.

We have worked with your presented scenario, and have noticed that most of the images generated (via SheetRender) are empty. Therefore you can reduce the number of generated images by ignoring the empty pages by utilizing the ImageOrPrintOptions.PrintingPage property. Please set it to PrintingPageType.IgnoreBlank in order to ignore the 24566 (out of 32769) blank pages.

Same property is available for the PdfSaveOptions class and can be used in same manner to ignore the blank pages.

Hope this helps a bit. Please feel free to write back in case you have any concerns or questions.

Thank’s for advice: we’re now using PrintingPageType.IgnoreBlank
and some other considerations in term of columns number and width and it seems to work pretty good

BUT we have still a question with page count:

using ignoreblank, OnePagePerSheet = true, and Cells.DeleteBlankColumns()
we obtain a good aspose.cells file and when we use this code:
Aspose.Cells.Rendering.SheetRender oSheetR = new Aspose.Cells.Rendering.SheetRender(((Aspose.Cells.Workbook)m_oDocument).Worksheets[i], OptionsC);
m_iPageCount += oSheetR.PageCount;

we have a pagecount of 1

but when we save object as PDF:

Aspose.Cells.PdfSaveOptions OptionsC = new Aspose.Cells.PdfSaveOptions();
OptionsC.AllColumnsInOnePagePerSheet = true;
OptionsC.PrintingPageType = Aspose.Cells.PrintingPageType.IgnoreBlank;
((Aspose.Cells.Workbook)m_oDocument).Save(_oOutputStream, OptionsC);

we get a 3 pages PDF files

So there is a way to know pdf pages (with AllColumnsInOnePagePerSheet = true) before saving pdf?

Hi Valerio,


First of all, please accept our sincere apologies for a bit delayed response.

I am afraid, there is no means available to get the page count before saving the spreadsheet to PDF format. However, you can get the PDF page count after saving the PDF to disk or memory while using the Aspose.Pdf for .NET API. Please see the sample code as follow.

C#

//open document
var pdfDocument = new Aspose.Pdf.Document(oOutputStream);
//get page count
Console.WriteLine(“Page Count : {0}”, pdfDocument.Pages.Count);

In case above doesn't fit your needs well, you an use the WorkbookRender class to get the page count while setting the AllColumnsInOnePagePerSheet to true. I have done some tests, and have received correct results from WorkbookRender.PageCount property. Please note, the WorkbookRender class behaves similar to SheetRender class for a complete spreadsheet, therefore it is not meant to render the results in PDF format. However, you may use this approach as a workaround to your presented scenario to get the page count.

C#

//open document
var m_oDocument = new Workbook(myDir + "sample.xlsx");
//initialize WorkbookRender with appropriate ImageOrPrintOptions settings var render = new WorkbookRender(m_oDocument, new ImageOrPrintOptions() { AllColumnsInOnePagePerSheet = true }); Console.WriteLine(render.PageCount);