我用的17.1.5,使用的是spread.print()打印方式打印的,你截图上边我的页脚没有了
我的代码如下:
<script type="text/javascript">
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("printArea1"));
var excelIo = new GC.Spread.Excel.IO();
var excelFilePath = "https://localhost:7218/EXCEL/555.xlsx";
var xhr = new XMLHttpRequest();
xhr.open('GET', excelFilePath, true);
xhr.responseType = 'blob';
xhr.onload = function (e) {
if (this.status == 200) {
// get binary data as a response
var blob = this.response;
// convert Excel to JSON
excelIo.open(blob, function (json) {
var workbookObj = json;
spread.fromJSON(workbookObj);
}, function (e) {
// process error
alert(e.errorMessage);
}, {});
}
};
xhr.send();
//spread.name = "555.xlsx";
document.getElementById('print1').onclick = function () {
var sheet = spread.sheets[0];
var printInfo = sheet.printInfo();
printInfo.showRowHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
printInfo.showColumnHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
var margintop = printInfo.margin().top;
var marginbottom = printInfo.margin().bottom;
var marginleft = printInfo.margin().left;
var marginright = printInfo.margin().right;
var marginheader = printInfo.margin().header;
var marginfooter = printInfo.margin().footer;
printInfo.margin({ top: 20, bottom: 20, left: 20, right: 20, header: 1, footer: 1 });
printInfo.showBorder(false);
var printHeaderRight = printInfo.pageHeaderFooter().normal.header.right;
printHeaderRight = printHeaderRight.replaceAll("\r\n", "")
var printFootRight = printInfo.pageHeaderFooter().normal.footer.right;
if (printFootRight == "&F") {
printFootRight = "調査計画表(2)_51_00_20241122145348.xlsx";
}
var orientation = spread.sheets[0].printInfo().orientation();
if (orientation == 2) {
printInfo.orientation(GC.Spread.Sheets.Print.PrintPageOrientation.landscape);
} else {
printInfo.orientation(GC.Spread.Sheets.Print.PrintPageOrientation.portrait);
}
printInfo.pageHeaderFooter({
normal: {
header: {
left: "",
center: "",
right: printHeaderRight
},
footer: {
center: "",
right: '調査計画表(2)_51_00_20241122145348.xlsx'
}
}
});
//spread.name = "555.xlsx";
spread.print();
};
</script>
打印出来就是两页,页脚移动到第二页了
|