Good morning,
is it possible with Aspose.Cells and/or any of the other libraries you offer to use a similiar functionality as the Aspose.Cells .SheetToImage() method already does (Excel area >> Image) but to create a .pdf out of that range?
Best regards,
-Joerg Battermann
Hi,
Yes, Aspose.Cells offers Xls2Pdf conversion feature, You will need to use Aspose.Cells for .NET and Aspose.Pdf components. Please check the following documentation topic for your reference:
Thank you.
Amjad,
this seems to work for entire Workbooks only, not small ranges within one of its worksheets… right? The later would be the particular usecase as I only want a small subset of data exported as .pdf
-J
Hi,
Yes, unless you set your desired printable area before saving the .xml (Aspose.Pdf integrated file) , you may try some pagesetup options: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/page-setup-features.html
e.g..,
workbook.Worksheets[0].PageSetup.PrintArea = "A1:N31";
And, I think you may delete using Worksheets.RemoveAt() method. or hide your unwanted worksheets for your need.
Thank you.
Amjad,
this works “almost” as wanted (I can perfectly hide unwanted worksheets etc and they do not show up in the .pdf, but the generated .pdf is always a full page, even though the printarea -is- set just around the cells and the margins are set to 5mm.
I’ll send you the pdf to show you what I mean…
-J
On top of that… is it possible to create .pdfs out of these print ranges that do not conform at all to common page sizes?
Hi,
I have received your .pdf file.
Could you post us your template excel file with sample code. Also, provide us complete details about those ranges, we will check it soon.
Thank you.
Hi,
We have received your template files and sample code with other details.
We will check it soon.
Thank you.
Hi,
After looking into your file(s), the pdf exported by xls2Pdf conversion is similar to the print result set of MS Excel. In Worksheet2Image conversion, we will change the image size according to printed data.
Please either extend the column width or use a smaller paper accordingly for your need.
Thank you.
Amjad,
I am not sure I understand correctly: do I have to create new paper sizes for each individual excel file to fit properly or how exactly would I get the same result as I do with the worksheet2image method?
-J
Hi,
Well, when you convert an xls/xlsx file to .pdf format, there might be slight difference related to the pagesetup attributes specially (e.g.., page heights / widths are not exactly the same, no. of pages may not be the same as Ms Excel shows in the preview etc.) for both formats i.e.., xls/xlsx and pdf have different sets of characteristics and are diverse architectures.
I think you need to do some workaround. You should try to set column widths accordingly for your requirements, check the doc topic for your reference: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/adjusting-row-height-column-width.html Alternatively you may try to set the paper size according to your data and requirements, check the doc topic: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/setting-page-options.html
Thank you.
Amjad,
is it possible to create my own, custom page sizes? I see there are several constants e.g. A4, US Letter etc… but what I want is a really custom size which is created/set during run-time?
-J
Hi,
I think you may try to set page margins for your need if it makes some difference: http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/setting-margins.html
Thank you.