<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for sharing the sample code.
We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id: CELLSNET-14883.
I have installed your updates and now when I want to build my solution in VIsual studio I get the following error message :
Error 9 'Aspose.Cells.FileFormatType' does not contain a definition for 'AsposePdf' E:\acbaASP_projetVS\App_Code\StaticClass\acbaPDF.cs 43 51 E:\acbaASP_projetVS\
Well, I tested the latest version with your sample code and template file and I did not find any issue. Please create a sample application with the latest version of Aspose.Cells to reproduce the issue and post it here. We will check it soon.
When I try to convert the workbook with the fix you provided. The pdf is not generated. Can you help me with this? This is urgent, I need this for today.
MemoryStream pdfStream = new MemoryStream(); testWorkbook.Save(pdfStream, FileFormatType.Pdf); byte[] pdfByteArray = pdfStream.GetBuffer(); //the byte array here as no element
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for sharing the sample code.
We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue have been registered in our internal issue tracking system with issue id: CELLSNET-15126.
Please try the attached version, we have fixed your mentioned issue. And, please use MemoryStream.ToArray() instead of MemoryStream.GetFuffer(). If you use MemoryStream.GetFuffer(), you might get a corrupted pdf file.
Here is my test code:
Workbook workbook = new Workbook(); workbook.Open(“e:\test\Mybook.xlsx”); MemoryStream ms = new MemoryStream(); workbook.Save(ms, FileFormatType.Pdf); ms.Seek(0, SeekOrigin.Begin); byte[] buffer = new byte[ms.Length]; buffer = ms.ToArray(); MessageBox.Show(ms.Length.ToString()); //It provides me the length. FileStream fs = new FileStream(“e:\test\MyPdfFile.pdf”, FileMode.Create); fs.Write(buffer, 0, buffer.Length); fs.Close(); ms.Close();
I've test it with the attach workbook and the resulting pdf as too much pages The pdf as over 3000 pages, but it should be 2 pages. Sometimes, I even get a OutOfMemory exception.
The legacy pdf conversion method had a way to determine where the excel sheet ends. Can you had this feature? Or is there a workaround? Please note that i can't setup print area as I don't know in advance how many data will be pull into the workbook.
Well, I have checked your template excel file. Using MS Excel’s print preview (PageSetup option), I can confirm it has over 2600 pages for the second worksheet and over 3000 pages for the third worksheet. Aspose.Cells will print/render all the pages (whether they have data or not) that are displayed in Print Preview in MS Excel by default. Moreover, if you could take a look the PageSetup dialog box opening the file in MS Excel, you will see that there are two reasons for this huge pages list.
1). Click the Sheet tab in Page Setup Dialog in MS Excel, you will see there are print areas set extensively for the second and the third worksheets, e.g (i) A1:I65535 for the second worksheet. (ii) A1:J65535 for the third worksheet.
2) Click the Sheet tab in Page Setup Dialog in MS Excel, you will see a value is given for the “Rows to repeat at top” for the second and the third worksheets, i.e.: $8:$11 for the second and the third worksheets.
So, when you will convert from the spreadsheets to Pdf file format, long list of pages would be rendered in the pdf document. Also, the process would be time consuming and will use extra memory to be completed. I think you need to set the Print areas and “Rows to repeat at top” accordingly to minimize your pages.
Well, I think for your case, you just remove the existing print area settings, it will work fine. When you remove the print area settings, MS Excel would only print that area in the sheet which has data in it, so the extra pages won’t be rendered in the Pdf format.