$.post(url, { xhId: Ids }, function (data) {
var temp = new GC.Spread.Sheets.Workbook(document.getElementById("copyExcel"));
var sheetcount = 0;
for (var i = 0; i < data.length; i++) {
temp.fromJSON(JSON.parse(data[i]));
sheetcount += temp.getSheetCount();
}
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("printExcel"), { sheetCount: sheetcount });
//console.log(spread.getSheetCount());
var sheetindex = 0;
for (var i = 0; i < data.length; i++) {
temp.fromJSON(JSON.parse(data[i]));
temp.getNamedStyles().forEach(function (namedStyle) {
namedStyle.name = "zzs" + sheetindex + namedStyle.name;
//console.log(namedStyle);
spread.addNamedStyle(namedStyle);
});
for (var j = 0; j < temp.getSheetCount(); j++) {
var sheet = temp.getSheet(j);
//console.log("sheetindex:"+sheetindex);
//console.log(sheet.name());
//console.log(sheet.name() + sheetindex.toString());
var sheetJson = JSON.stringify(sheet.toJSON());
sheetJson = sheetJson.replace(/\"style\":\"/g, '"style":"zzs' + sheetindex);
spread.suspendPaint();
spread.getSheet(sheetindex).fromJSON(JSON.parse(sheetJson));
spread.sheets[sheetindex].name(sheet.name() + sheetindex.toString());
spread.resumePaint();
sheetindex++;
}
}
$scope.print(spread);
}); |