会在下个版本中修复,现在有个workaround 方法,参考:
- // 追加表单逻辑
- function mergeWorkbook() {
- spread.suspendPaint();
- temp.getNamedStyles().forEach(function (namedStyle) {
- if (namedStyle.name.startsWith("__builtInStyle")) {
- namedStyle.name = mergeFlag + importFlag + namedStyle.name.replace("__builtInStyle", "builtInStyle");
- } else {
- namedStyle.name = mergeFlag + importFlag + namedStyle.name;
- }
- //console.log(namedStyle);
- spread.addNamedStyle(namedStyle);
- });
- for (var i = 0; i < temp.getSheetCount(); i++) {
- var sheet = temp.getSheet(i);
- //console.log(sheet.name());
- var sheetJson = JSON.stringify(sheet.toJSON());
- sheetJson = sheetJson.replace(/"style":"__builtInStyle/g, '"style":"builtInStyle');
- sheetJson = sheetJson.replace(/"style":"/g, '"style":"'+mergeFlag+ + importFlag);
- // 把parentName也统一
- sheetJson = sheetJson.replace(/"parentName":"__builtInStyle/g, '"parentName":"builtInStyle');
- sheetJson = sheetJson.replace(/"parentName":"/g, '"parentName":"'+mergeFlag+ + importFlag);
- var newSheet = new GC.Spread.Sheets.Worksheet("newSheet");
- console.log(sheetJson);
- newSheet.fromJSON(JSON.parse(sheetJson));
- newSheet.name(sheet.name() + "_" + mergeFlag + "_" + importFlag);
- spread.addSheet(spread.getSheetCount(), newSheet);
- }
- importFlag++;
- spread.resumePaint();
- }
复制代码
|