Modify page orientation in xlxs export
Modify page orientation in xlxs export
seb1978
Posts: 2Questions: 1Answers: 0
Is it possible to select portrait or landscape orientation of xlxs exported file (print preview) ??
thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Probably by modifying the XLSX file (which you can do using the
customize
callback of theexcelHtml5
button type), but there isn't a built in option for that, and you'd need to look up the Open Spreadsheet documentation to find out what the correct syntax in the XML for that is.Allan
thanks
for example modify in buttonhtml5.js
var excelStrings = { ...
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'+
'<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">'+
'<sheetData/>'+
_ //add this for page format A4 and orientation landscape_
'<pageSetup paperSize="9" orientation="landscape" r:id="rId1" />'+
'</worksheet>',
...
or
customize: function(xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
orientation = "landscape"; //landscape or portrait
},
in buttonhtml5.js
var orientation;
var excelStrings = { ...
'<pageSetup paperSize="9" orientation='+orientation+' r:id="rId1" />'+
...
Sébastien L.
That's awesome - thanks for posting back with that information. I'm sure others will find it to be useful as well!
Allan
Without modifying the buttonhtml5.js, you can do it with a little xml trick
....
customize: function( xlsx ) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var pageSet = sheet.createElement("pageSetup");
sheet.childNodes["0"].appendChild(pageSet);
var seiteneinstellung = sheet.getElementsByTagName("pageSetup")[0];
seiteneinstellung.setAttribute("paperSize", "9");
seiteneinstellung.setAttribute("orientation", "landscape");
seiteneinstellung.setAttribute("r:id", "rId1"); }
}
...
Peter