Home » excel » Controlling print preview defaults in Excel XML

Controlling print preview defaults in Excel XML

Posted by: admin May 14, 2020 Leave a comment

Questions:

With Excel XML and embedded stylesheets you can control many aspects of the appearance of the spreadsheet.

Is there a way to control the defaults on the Print Preview page? Specifically I would like to set the page size to 1 page by 1 page.

How to&Answers:

Within SpreadsheetML (Excel 2003 XML) the FitToPage is an element within the WorksheetOptions element. It also depends on the elements FitWidth and FitHeight within the Print element there.

Example:

    <?xml version="1.0"?>
    <?mso-application progid="Excel.Sheet"?>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
     xmlns:o="urn:schemas-microsoft-com:office:office"
     xmlns:x="urn:schemas-microsoft-com:office:excel"
     xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
     xmlns:html="http://www.w3.org/TR/REC-html40">
...
     <Worksheet ss:Name="Tabelle1">
      <Table>
       <Row>
        <Cell><Data ss:Type="Number">123</Data></Cell>
...
       </Row>
...
      </Table>
      <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
       <FitToPage/>
       <Print>
        <FitWidth>1</FitWidth>
        <FitHeight>1</FitHeight>
       </Print>
      </WorksheetOptions>
     </Worksheet>
    </Workbook>

Greetings

Axel