v17使用sheet.cellStates.add()后spread.export()使用时报错
v17使用sheet.cellStates.add()后spread.export()使用时报错sheet.cellStates.add(range,GC.Spread.Sheets.CellStatesType.selected,{backColor: '#93d2f3'});
function FnexportXlsx() {
console.log(spread)
spread.export(function (blob) { // save blob to a file
saveAs(blob, cardEareref.value?.cardindex?.name || sheetName.value);
},
function (e) { console.log(e); },
{ fileType: GC.Spread.Sheets.FileType.excel, includeBindingSource: true });
}
o.toJSON is not a functionTypeError: o.toJSON is not a function at v (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:1185527) at l.toJSON (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:1188874) at h.toJSON (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:1193235) at z.wh (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:1194806) at Object.eval (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:860825) at y0 (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:3955286) at z.wh (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:860794) at k.K.Workbook.wh (webpack-internal:///./node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js:11:503439) at k.A.Workbook.save (webpack-internal:///./node_modules/@grapecity-software/spread-sheets-io/dist/gc.spread.sheets.io.min.js:300:10691) at k.A.Workbook.export (webpack-internal:///./node_modules/@grapecity-software/spread-sheets-io/dist/gc.spread.sheets.io.min.js:300:9538)
王五子 发表于 2024-12-20 09:05
用style已经可以了,是因为背景色对象影响了export序列化成JSON字符串么?
不是因为背景色,而是对象的定义方式。
SpreadJS内部包含有大量的对象,序列化时需要根据这些对象的类型将每个对象序列化。对于对象字面量而言,没有确切的类型,无法正常序列化。
建议在您需要使用SpreadJS的序列化功能时,使用通过new创建的对象,而非对象字面量。 您好!通过您提供的代码片段,了解到您在设置背景颜色时使用了对象字面量,应该使用Style对象设置。 Wilson.Zhang 发表于 2024-12-20 08:51
您好!通过您提供的代码片段,了解到您在设置背景颜色时使用了对象字面量,应该使用Style对象设置。
用style已经可以了,是因为背景色对象影响了export序列化成JSON字符串么? 注意到楼主长时间未回复,那本贴就先结贴了,有问题欢迎另开新帖交流
页:
[1]