Posted 17 March 2023, 1:48 am EST
Hi!
Is there any way to get the name of the author of an excel file after import?
Forums Home / Spread / SpreadJS
Posted by: Fabrice.Mainguene on 17 March 2023, 1:48 am EST
Posted 17 March 2023, 1:48 am EST
Hi!
Is there any way to get the name of the author of an excel file after import?
Posted 19 March 2023, 10:04 pm EST
Hello,
When you load an excel file using excelio.open() method, you get the json of the loaded excel file in a callback function. The json of excel file contains a property docProps.docPropsCore.creator which contains the name of the author of the file. You can store this name in a variable and use later whenever you need it.
Please refer to the code snippet and attached sample for further understanding.
let authorName = ‘’;
document.getElementById(‘import’).addEventListener(‘click’, (e) => {
let file = document.getElementById(‘file’).files[0];
if (!file) {
return;
}
let excelio = new Excel.IO();
excelio.open(file, (json) => {
if (json.docProps) {
authorName = json.docProps.docPropsCore.creator;
}
spread.fromJSON(json);
}, console.log);
});
Sample: https://jscodemine.grapecity.com/share/f2PUQcjT40SluC6FCyBGXA/?defaultOpen={“OpenedFileName”:[“/index.html”,“/src/app.js”],“ActiveFile”:“/src/app.js”}
Please let us know if you face any difficulties.
Doc reference
excelio.open():https://www.grapecity.com/spreadjs/api/excelio/classes/Excel.IO-1#open
spread.fromJSON(): https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Workbook#fromjson