0

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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
VPP
  • 731
  • 1
  • 9
  • 34
  • I removed the [tag:itextsharp] tag. I don't see any reason why this question should be tagged as an iText-related question. – Bruno Lowagie Jun 04 '14 at 17:03

2 Answers2

1

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.

aucuparia
  • 2,021
  • 20
  • 27
  • That isn't helping. PageSetup seems to be a attribute or Excel.Worksheet and not Excel.WorkbookClass which is my thing. I tried with Worksheet but it went in vein. Any other suggestions? – VPP Jun 04 '14 at 18:43
  • Sorry, my bad. You need to set the `PageSetup` property on each sheet you're exporting. I've edited the answer. Obviously replace "sheetname" with the name of the appropriate sheet, or a number (sheets are indexed from 1), or use `for each ws in WrkBook.WorkSheets...Next` to loop through them all. – aucuparia Jun 04 '14 at 21:47
0
worksheet.PageSetup.Zoom = false

provided me all columns in one page.

Anyways Thanks a ton!! aucuparia, you made me look into Pagesetup properties.

VPP
  • 731
  • 1
  • 9
  • 34