Free Support Forum - aspose.com

Convert excel to pdf without first saving excel file or pdf file

is there a way to call


ConvertExcelFileToPDF(TEMPLATE_FILE_PATH,“ExcelFileToPDF.pdf”);

when you haven’t saved the excel file.  
You just want to pass a workbook to it or something like that?
And then stream the pdf back to client.  This is an attempted workaround 
to a problem I discovered in aspase pdf in that it won’t display my images 
in a created from scratch pdf.

Hi,

Thanks for your posting and using Aspose.Cells.

Aspose.Cellls can only convert your Excel file into pdf , it cannot convert your pdf file into excel. Please see the following documents for your reference. Aspose.Cells cannot convert Excel to pdf without saving.

http://www.aspose.com/docs/display/cellsjava/Opening+Files
http://www.aspose.com/docs/display/cellsjava/Saving+Files
http://www.aspose.com/docs/display/cellsjava/Converting+to+PDF+Files

are there any options when saving a workbook as a pdf? By default it split my table across six pages. It fits all on one page when I create the same pdf using aspose.pdf from scratch. Is there a way to make it all on one page with the saving of workbook as a pdf?

Hi,

Thanks for your posting and using Aspose.Cells.

Please see the following code ,it would print entire sheet on one page.

Java


String path = “F:\Shak-Data-RW\Downloads\test\sample\sample.xls”;


Workbook workbook = new Workbook(path);


PdfSaveOptions opts = new PdfSaveOptions();

opts.setOnePagePerSheet(true);


workbook.save(path + “.out.pdf”, opts);

Thank you, that worked. Is there any way to control line breaks in the table headers in excel? Some of the headers are long. When I use aspose.pdf to generate a pdf it reads the line breaks in the messages \n but in excel it just ignores the \n. So when I convert to pdf it still has the long table headers all on one line.

OK, is there a way to turn on the grid lines when converting xcel to pdf. I think I read that somewhere but can’t seem to find it now.

Hi,

Thanks for your posting and using Aspose.Cells.

You may use the following line of code before saving to pdf.e.g

workbook.getWorksheets().get(0).getPageSetup().setPrintGridlines(true);