views:

133

answers:

2

I have an XML Spreadsheet that is automatically generated. There is a varying amount of Columns and Rows depending on the report.

When printing I would like for it to Fit to Width (Right now if there are too many columns it will not fit on a page... even when landscape).

I was initially using FitToPage but for reports with hundreds of rows it needs to go onto multiple pages.

Any suggestions on how to do this?

A: 

In VBA I'd use

.FitToPagesWide = 1

off of the PageSetup property of the sheet.

Lance Roberts
[Don't forget](http://stackoverflow.com/questions/2509583/excel-2007-pagesetup-fittopageswide-problem/2509715#2509715) to set `Zoom` to `False`!
Andrew Grimm
A: 

Figured it out...

You have to use FitToPage

And FitHeight (which sets the number of pages to print to) to get it to fit to width and have multiple pages...

Here is an example of it working.

<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
       <PageSetup>
        <Layout x:Orientation="Landscape"/>
        <Header x:Margin="0.3"/>
        <Footer x:Margin="0.3"/>
        <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
       </PageSetup>
       <FitToPage/>
       <Print>
        <FitHeight>100</FitHeight>
        <ValidPrinterInfo/>
        <HorizontalResolution>600</HorizontalResolution>
        <VerticalResolution>600</VerticalResolution>
       </Print>
       <Selected/>
       <Panes>
        <Pane>
         <Number>3</Number>
         <ActiveRow>6</ActiveRow>
         <ActiveCol>8</ActiveCol>
        </Pane>
       </Panes>
       <ProtectObjects>False</ProtectObjects>
       <ProtectScenarios>False</ProtectScenarios>
      </WorksheetOptions>
mc6688