I generate .xlsx documents in my solution and send them to the user, when parsed with js-xlsx they have zero cells, this can be fixed by opening the generated .xlsx with Excel and saving them.
I would like to be able to parse my generated .xlsx documents directly with js-xlsx.
Code for saving to .xlsx:
var ms = new MemoryStream();
workbook.SaveAs(ms);
ms.Seek(0, SeekOrigin.Begin);
return ms;var ms = new MemoryStream();
Code for opening .xlsx with js-xlsx:
function readBook(file) {
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, { type: 'binary' });
console.log(workbook);
};
reader.readAsBinaryString(file);
}
I found that c# OpenXML adds 'x:' in front of all the string xml tags, this can be fixed in js-xlsx by replacing the 'x:' tags.
simply put:
data = data.replace(new RegExp('x:', 'g'), '');
into function parse_ws_xml(data, opts, rels) and function parse_sst_xml(data, opts)
Todo: make a fix that allows you to have strings containing 'x:' in your .xlsx file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.