var workbook=$("#"+widgetId).data("workbook");
var sheet = workbook.getActiveSheet();
var printInfo = sheet.printInfo();
var print = JSON.parse(printt);
var printset={};
if(print){
if(print["tMargin"]&&print["tMargin"]!="null"){
printset["top"]=Number(print["tMargin"]);
}
if(print["bMargin"]&&print["bMargin"]!="null"){
printset["bottom"]=Number(print["bMargin"]);
}
if(print["lMargin"]&&print["lMargin"]!="null"){
printset["left"]=Number(print["lMargin"]);
}
if(print["rMargin"]&&print["rMargin"]!="null"){
printset["right"]=Number(print["rMargin"]);
}
if(print["headerMargin"]&&print["headerMargin"]!="null"){
printset["header"]=Number(print["headerMargin"]);
}
if(print["ftMargin"]&&print["ftMargin"]!="null"){
printset["footer"]=Number(print["ftMargin"]);
}
}
if(print["zoomScale"]&&print["zoomScale"]!="null"){
printInfo.zoomFactor(Number(print["zoomScale"]));
}
if(print["orient"]=="2"){
printInfo.orientation(GC.Spread.Sheets.Print.PrintPageOrientation.landscape);//横向
}else{
printInfo.orientation(GC.Spread.Sheets.Print.PrintPageOrientation.portrait);//纵向
}
if(print["printGrid"]=="1"){
printInfo.showGridLine(true);
}else{
printInfo.showGridLine(false);
}
printInfo.showBorder(false);
printInfo.showColumnHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
printInfo.showRowHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
var paperSizeMap={
"null":GC.Spread.Sheets.Print.PaperKind.a4,
"8":GC.Spread.Sheets.Print.PaperKind.a3,
"11":GC.Spread.Sheets.Print.PaperKind.a5,
"66":GC.Spread.Sheets.Print.PaperKind.a2,
"70":GC.Spread.Sheets.Print.PaperKind.a6
};
if(print["paperSize"]){
var paperKind;
if(print["paperSize"]!=null){
paperKind = paperSizeMap[print["paperSize"]];
}else{
paperKind = print["paperSize"];
}
printInfo.paperSize(new GC.Spread.Sheets.Print.PaperSize(paperKind));
}
if(print["repeatRowStart"]!=null){
printInfo.repeatRowStart(Number(print["repeatRowStart"])-1);
}
if(print["repeatRowEnd"]!=null){
printInfo.repeatRowEnd(Number(print["repeatRowEnd"])-1);
}
if(print["cFtTitle"]!=null){
printInfo.footerCenter(print["cFtTitle"]);
}
if(print["cHeaderTitle"]!=null){
printInfo.headerCenter(print["cHeaderTitle"]);
}
if(print["lFtTitle"]!=null){
printInfo.footerLeft(print["lFtTitle"]);
}
if(print["lHeaderTitle"]!=null){
printInfo.headerLeft(print["lHeaderTitle"]);
}
if(print["rFtTitle"]!=null){
printInfo.footerRight(print["rFtTitle"]);
}
if(print["rHeaderTitle"]!=null){
printInfo.headerRight(print["rHeaderTitle"]);
}
var pageRows = Number(print["pageRows"])
if(pageRows!=0){
var rowCount = sheet.getRowCount();
for(var r=1;r<=rowCount;r++){
if(r%pageRows==0){
sheet.setRowPageBreak(r, true);
}
}
}
printInfo.margin(printset);
workbook.print();
|
|