Generar XLS con opciones de Impresión desde una aplicación web con HTML

Para añadir opciones de impresión (hoja apaisada, tamaño de margenes, etc) a un excel usando HTML debe agregarse el siguiente codigo (modificarlo segun necesidad, solo funciona con office > 2007):
Debajo de <head>:
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
 <o:Author>Pat Willener</o:Author>
 <o:Company>Good Day Books</o:Company>
 </o:DocumentProperties>
 <o:OfficeDocumentSettings>
 <o:RelyOnVML/>
 <o:AllowPNG/>
 </o:OfficeDocumentSettings>
</xml><![endif]-->

En <style>:
@page
 {mso-header-data:"&CInventory";
 mso-footer-data:"Page &P of &N";
 margin:.31in 0in .31in 0in;
 mso-header-margin:0in;
 mso-footer-margin:0in;
 mso-page-orientation:landscape;}
Debajo de </style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
 <x:ExcelWorksheets>
 <x:ExcelWorksheet>
 <x:Name>Inventory</x:Name>
 <x:WorksheetOptions>
 <x:Print>
 <x:ValidPrinterInfo/>
 <x:PaperSizeIndex>9</x:PaperSizeIndex>
 <x:HorizontalResolution>600</x:HorizontalResolution>
 <x:VerticalResolution>600</x:VerticalResolution>
 </x:Print>
 <x:Selected/>
 <x:Panes>
 <x:Pane>
 <x:Number>1</x:Number>
 <x:ActiveRow>1</x:ActiveRow>
 </x:Pane>
 </x:Panes>
 <x:ProtectContents>False</x:ProtectContents>
 <x:ProtectObjects>False</x:ProtectObjects>
 <x:ProtectScenarios>False</x:ProtectScenarios>
 </x:WorksheetOptions>
 </x:ExcelWorksheet>
 </x:ExcelWorksheets>
 <x:WindowHeight>8835</x:WindowHeight>
 <x:WindowWidth>15180</x:WindowWidth>
 <x:WindowTopX>120</x:WindowTopX>
 <x:WindowTopY>105</x:WindowTopY>
 <x:ProtectStructure>False</x:ProtectStructure>
 <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]-->

Dentro de <body>, agrupar todo el contenido en un div class Section1
<body>
<div class=Section1>
.
.
</div>
</body>

Comentarios

Entradas populares