Exportasfixedformat breaking excel (excel to pdf)
-
21-12-2019 - |
Question
I'm trying to use this Exportasfixedformat method to convert from .xls, to pdf. It works, but its behavior is quite strange.
my excel is like this:
column 1 |column 2 |column 3 |column 4 |column 5 |column 6 |column 7 |column 8 |column 9
and the pdf is like this:
column 1 |column 2 |column 3 (in the first page) column 4 |column 5 |column 6 (in the second page) and so on....
I tried both
WrkBook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, aPathFile)
WrkBook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, aPathFile, Excel.XlFixedFormatQuality.xlQualityStandard, True, False, 1, 1, False, System.Reflection.Missing.Value)
I would like to display all columns on one page Any suggestions? Please help
I use Itextsharp.
Solution 2
worksheet.PageSetup.Zoom = false
provided me all columns in one page.
Anyways Thanks a ton!! aucuparia, you made me look into Pagesetup properties.
OTHER TIPS
The ExportAsFixedFormat
method uses the page setup (i.e. how the workbook appears when printed) to render the file. To get all the columns on one page, set
WrkBook.WorkSheets("sheetname").PageSetup.FitToPagesWide = 1
before exporting. The (many) other properties of PageSetup
will also affect the results.