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

Free Support Forum - aspose.com

Converting XLSX to PDF - Rendering all columns of worksheet in one page in .NET

Hi

I will try to convert xlx,xlsx to pdf file,what i get in pdf file, each page i get each column of xlsx data,pls see the pdf and xlsx file.

But in ur example ,all column show in only one pdf page
http://www.aspose.com/docs/display/cellsnet/Converting+Excel+to+PDF+Files

i am use this line

’Instantiate the Workbook object
'Open an Excel file
Dim workbook As New Workbook(myDir & “Book1.xls”)

'Save the document in PDF format
workbook.Save(myDir & “outBook.pdf”, SaveFormat.Pdf)



pls check and reply asap


Regards
  Aravind

Hi,


Aspose.Cells renders PDF files based on what is shown in Print Preview of MS Excel. If you could open your template file into MS Excel manually and see the Print Preview of the sheet, you will also see that it spans into 3 pages and columns are splitted into multiple pages, so the PDF is right generated by Aspose.Cells. Well, for your requirements, you may try to use PdfSaveOptions.AllColumnsInOnePagePerSheet to set it to true to ensure all the columns should be rendered on single PDF page (if possible). Please see the sample code for your reference that works fine for your needs.
e.g
Sample code:


Workbook xlsAspose = new Workbook(“e:\test2\Time.xlsx”);
PdfSaveOptions saveOpt = new PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
saveOpt.AllColumnsInOnePagePerSheet = true;
xlsAspose.Save(“e:\test2\outBook1.pdf”, saveOpt);


Hope, this helps a bit.

Thank you.

Hi


Can u provide in vb language with namespace added in its opject
like

Dim saveOpt As Aspose.Pdf.PdfSaveOptions = New Aspose.Pdf.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf),but in this line i will get error on the arugument like "Too many arguments to 'Public Sub New() "



Workbook xlsAspose = new Workbook(“e:\test2\Time.xlsx”);
PdfSaveOptions saveOpt = new PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
saveOpt.AllColumnsInOnePagePerSheet = true;
xlsAspose.Save(“e:\test2\outBook1asdfasdf1.pdf”, saveOpt);

Note: i am add Aspose.Totall dlls,so all dll imported and namespace also import like Aspose.words,Aspose.Pdf,Aspose.Cells,

so pls specify the namespace for it object declaration.


Regards
Aravind

Hi,


Please use fully qualified naming for creating objects for Aspose.Cells APIs (there are some APIs with similar names in different products, so it is better to use fully qualified names for the objects, etc.). See the sample code below:
[VB]
e.g
Sample code:

Dim xlsAspose As Aspose.Cells.Workbook = New Aspose.Cells.Workbook(“e:\test2\Time.xlsx”)
Dim saveOpt As Aspose.Cells.PdfSaveOptions = New Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf)
saveOpt.AllColumnsInOnePagePerSheet = True
xlsAspose.Save(“e:\test2\outBook1.pdf”, saveOpt)

Hope, this helps a bit.

Thank you.


Hi

Thanks,it work now

Hi,


Good to know that it works for you now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.