其他方法解决的,思路如下:1.线解决打印辅助线
// 第四页打印辅助线设置
handelSheet4PrintLine() {
let sheetCount = this.spread.getSheetCount();
for (let i = 0; i < sheetCount; i++) {
let sheet = this.spread.getSheet(i);
let printInfo = sheet.printInfo();
if (i == 3) {
printInfo.repeatRowStart(0);
printInfo.repeatRowEnd(3);
sheet.isPrintLineVisible(true);
printInfo.showBorder(false);
printInfo.showGridLine(false);
printInfo.centering(GC.Spread.Sheets.Print.PrintCentering.horizontal);
printInfo.showColumnHeader(
GC.Spread.Sheets.Print.PrintVisibilityType.hide
);
printInfo.showRowHeader(
GC.Spread.Sheets.Print.PrintVisibilityType.hide
);
printInfo.fitPagesWide(1);
// printInfo.zoomFactor(1);
printInfo.paperSize(
new GC.Spread.Sheets.Print.PaperSize(
GC.Spread.Sheets.Print.PaperKind.a4
)
);
printInfo.margin({
top: 52.5,
bottom: 100,
left: 62.987,
right: 62.891,
header: 30,
footer: 0,
});
printInfo.orientation(
GC.Spread.Sheets.Print.PrintPageOrientation.portrait
);
}
}
},
2.设置其他页打印样式
// 设置sheet1,sheet2,sheet3打印样式样式
handelPrintStyleLine() {
let sheetCount = this.spread.getSheetCount();
for (let i = 0; i < sheetCount; i++) {
let sheet = this.spread.getSheet(i);
let printInfo = sheet.printInfo();
if (i != 3) {
sheet.isPrintLineVisible(true);
printInfo.showBorder(false);
printInfo.showGridLine(false);
printInfo.centering(GC.Spread.Sheets.Print.PrintCentering.horizontal);
printInfo.showColumnHeader(
GC.Spread.Sheets.Print.PrintVisibilityType.hide
);
printInfo.showRowHeader(
GC.Spread.Sheets.Print.PrintVisibilityType.hide
);
printInfo.centering("horizontal");
printInfo.fitPagesWide(1);
printInfo.paperSize(
new GC.Spread.Sheets.Print.PaperSize(
GC.Spread.Sheets.Print.PaperKind.a4
)
);
printInfo.margin({
top: 52.5,
bottom: 100,
left: 62.987,
right: 62.891,
header: 30,
footer: 0,
});
printInfo.orientation(
GC.Spread.Sheets.Print.PrintPageOrientation.portrait
);
}
}
},
3.页码设置
// 页码设置 --sheet1和sheet2不计算页码
setPageNumber() {
let sheetCount = this.spread.getSheetCount();
let sheet2PageInfo3 = "";
let sheet2PageInfo4 = "";
let sheet2PageCount = "";
let sheet2PageInfo5 = "";
sheet2PageInfo3 = this.spread.pageInfo(2);
sheet2PageInfo4 = this.spread.pageInfo(3);
if (sheetCount > 4) {
sheet2PageInfo5 = this.spread.pageInfo(4);
sheet2PageCount =
sheet2PageInfo3.pages.length +
sheet2PageInfo4.pages.length +
sheet2PageInfo5.pages.length;
} else {
sheet2PageCount =
sheet2PageInfo3.pages.length + sheet2PageInfo4.pages.length;
}
for (let i = 0; i < sheetCount; i++) {
let sheet = this.spread.getSheet(i);
let printInfo = sheet.printInfo();
printInfo = this.spread
.getSheet(i)
.printInfo()
.firstPageNumber(i - 1);
console.log(printInfo, "printInfo");
if (i > 1) {
printInfo.headerRight(
'\&"SimSun"第 ' + "&P 页 共 " + sheet2PageCount + " 页"
);
}
}
}, |