Posted 5 June 2024, 8:25 pm EST
Hi,
As per my understanding, you wish to preserve custom properties after importing and exporting in JSON.
To achieve this, you have been trying to access internal properties/methods in version 15 to achieve your requirement, but in version 17, it is not working. Since you are using internal properties/methods, they can change or be removed in higher versions, which is not recommended.
Instead, you can store custom properties in tags. These tags will be preserved even after importing and exporting the file in JSON. Note that tags are a SpreadJS-specific feature, so if you export to Excel, the tags will be cleared. Refer to the attached snippet and sample.
function initSpread(spread) {
// init spread
var sheet = spread.getActiveSheet();
const custom = {
message: "Hello world"
}
const str = JSON.stringify(custom);
sheet.setTag(0,0, str);
}
designer.bind(GC.Spread.Sheets.Designer.Events.FileLoaded, (event, data)=>{
console.log("file has loaded");
const tag = spread.getActiveSheet().getTag(0,0);
const custom = JSON.parse(tag);
console.log(custom.message);
});
Sample: https://jscodemine.mescius.io/share/it52AbL3jkKDXcPbPOu12A/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fpackage.json"%2C"%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}
If there is any misunderstanding of your requirement, could you please elaborate more and explain your exact use case so that we can assist you better?
Regards,
Priyam