sheetjs icon indicating copy to clipboard operation
sheetjs copied to clipboard

Dynamic read XLS from URL & append rows before making it available for download

Open techie28 opened this issue 7 years ago • 1 comments

Hello, May be this is not the right platform to raise a question. I need to read a file via a URL like http://abc.com/File.xlsx. This file has some formula fields,Rows would be dynamically added into the read XLS which would be presented to user for download. The formulas should stay intact as they will work when user will fill the data in downloaded XLS. Is this possible using JS XLSX. I learnt about the functions like "sheet_add_json" & to read file as "arraybuffer" but cant figure out how to get headers to write data into it. The file in the URL could be dynamic i.e could have different number of headers at different times. Please guide me.

techie28 avatar Dec 14 '18 11:12 techie28

To read the headers of a worksheet, you can just grab the first row from the AOA conversion:

var range = XLSX.utils.decode_range(ws["!ref"]);
range.e.r = 0;
var first_row = XLSX.utils.sheet_to_json(ws, {range: range, header: 1})[0]

SheetJSDev avatar Jan 23 '19 22:01 SheetJSDev