mgcrea / node-xlsx Goto Github PK
View Code? Open in Web Editor NEWNodeJS excel file parser & builder
License: Other
NodeJS excel file parser & builder
License: Other
Hi there! Is there a way to read in data from an Excel sheet so that it retains the date? When I try to read in date-formatted columns (such as 11/4/14) it gives it a value of 41947 in the JSON object.
Hey, guys, here is a problem I got: There is a column in my xlsx file that is to describe time. And if I input a '#8:30', then it can parse it right because the value is a string. But once I input '08:30', firstly the excel will change the value in to a date type, and then node-xlsx will parse it into a decimal type, now the value become 0.3541666666666667. I can't figure it out. I will appreciate it if someone can tell me how to deal with it. Thanks.
[email protected] is deprecated and does not work anymore.
It can be checked here.
It must be upgraded to at least 0.9.2.
in helpers.js the buildExcelDate function returns the wrong date in the case that !is1904
It should read:
const buildExcelDate = (value, is1904) => {
if(is1904) value+=1462;
const epoch = Date.parse(value);
return (epoch - originDate) / (24 * 60 * 60 * 1000)
};
Don't you have an error callback?
I used it to parse xls successfully.
however when I use it to parse xls documents again,it shows the message.
TypeError:Cannot set property length of [Object Object] which has only a getter
at dbcs_d (node-xlsx\node_modules\xlsx\dist\cpexcel.js:989:20)
at Object.decode (node-xlsx\node_modules\xlsx\dist\cpexcel.js:1197:40)
at _gc2 (node-xlsx\node_modules\xlsx\xlsx.js:28:24)
at Buffer.ReadShift as read_shift
at parse_ShortXLUnicodeString (node-xlsx\node_modules\xlsx\xlsx.js:3082:21)
at Object.parse_Font as f
at slurp (node-xlsx\node_modules\xlsx\xlsx.js:9229:11)
at parse_workbook (node-xlsx\node_modules\xlsx\xlsx.js:9350:15)
at parse_xlscfb (node-xlsx\node_modules\xlsx\xlsx.js:9827:27)
at Object.readSync as read
Hi, from the documentation, it is not clear (to me). Does this lib support streaming reads of sheets in an Excel workbook? I want to work with potentially huge sheets of data without loading all into memory.
Posted {"size":54272,"path":"/var/folders/7r/52ncf525795fy1pz4mtwps1m0000gn/T/68a874f48575058f0c78acfbd8b0f5fe","name":"QTL_Sample_data.xls","type":"application/vnd.ms-excel","mtime":"2014-10-16T18:37:22.655Z"}
Error thrown for request: /test
Error: Corrupted zip : can't find end of central directory
Getting this when I try and upload an XLS file, any suggestions?
Hello,
Can we also do plotting in addition to inserting data ?
Thanks
As the option parameter is common to the build, they apply to all sheets ; which is a problem toward merging of cells : I'd like to merge cells in a sheet but not the others.
Thx for the package it's great
I may be missing something simple, but how can I determine if the xls or xlsx is valid? Parsing is working great for valid files, but invalid files are crashing my node.js / sails.js application with a "Unsupported file 117" or 97 error when I run XLSX.readFile(//myUploadedfile) on an invalid file. How can I catch this error? Can I get a return from xlsx to determine if a file is a valid xls or xlsx prior to trying to parse it? Do I need to first determine it is valid outside of XLSX, if so any suggestions on method? Again, I apologize if I missed something in the documentation. If not included, it could be a good beginner item to add to documentation.
I have a excel with multiple sheets with less than 1000 rows in each sheet but for each sheet it gives me 65536 rows, I cannot loop 65k times on empty data to read just 100 rows
this could read max size of excel? my file'size is greater than 70MB
Is there a previous release (https://github.com/mgcrea/node-xlsx/releases) of this module that was compatible with ES5?
It's not clear from the version notes.
Thanks!
Javascript heap out of memory when trying to build a XLSX for a modest set of 133 rows of 3 columns in Node. The error is caused by buildSheetFromMatrix.
i keep getting this warning when i try to pen xlsx file generated by node-xlsx ,
Excel could not open mySheetName (1).xlsx because some content is unreadable. Do you want to open and repair this workbook?
I want set the width of each columns.Then i view the source code,but I didn't find the api.
May you help me? I don't know how to span columns or rows
If I issue multiple JSON in "build", e.g.
var buffer = xlsx.build([{name: "mySheetName", data: data}, {name: "mySheetName1", data: data}]);
Should I be able to create mutiple sheets in the workbook? I tried but only one sheet is created. I just want to confirm if this is the case.
RT
As you know, the license does not permit running code outside of windows. According to npm/npm#5339 (comment) :
the module author should set "os" in package.json to "win32" https://www.npmjs.org/doc/files/package.json.html#os
I use it to exports excel but got an error ,I need you help ,thanks you very much.
var excelData = _xlsx2.default.write(workBook, Object.assign({}, defaults, o
^
TypeError: undefined is not a function
I came across the following comment: SheetJS/sheetjs#99 (comment)
Is this project deprecated?
I think the method signature of the build method did not change. But since the update to 0.7.1 Version of node-xlsx i always get the error: undefined is not a function in node_modules/node-xlsx/lib/index.js:46:57
using version 0.6.0 the export works pretty fine....
Any thoughts on this?
I am unable to read the password protected sheets .
Can anyone explain what is the problem
Is it possible to parse XLS files with this plugin? I have been able to parse XLSX so far but no luck with the XLS files.
If there are two or more format in a cell , it will parse error with the cell value!
Open the same file.
In Linux(Ubuntu) the carriage return is:
example text\n\n
But Windows is:
example text\r\n
So if I want to deal with the carriage return character in different platform, What is the best way?
Appreciate!
I am unable to read the password protected sheets .
Can anyone explain what is the problem
Right now, Whatever I store is saving as strings (even Integers). Is there a way where I can format a cell as Integer.
I want to cpmplete cell merge,but i don't konw how to setting options
if you see that
reply me
thx
Hi,
What do you think about paralleling this lib somehow? Working with xls seems to mostly CPU-bound and therefore not very good to deal with in event loop thread.
https://github.com/SheetJS/js-xlsx this lib, used by this project supports web workers. On the other hand there is an implementation of web workers for node.js - https://www.npmjs.com/package/webworker-threads .
Thanks for your work!
Hi
Leading spaces are trimmed in the output file.
I need my data as it is and don't want any trim functionality. How can i achieve it ?
xlsx.parse sometimes right, but sometimes wrong, then throw error :
Corrupted zip : can't find end of central directory Error: Corrupted zip : can't find end of central directory
Till version 0.4 input was given like :
[{"value":"Name","bold":true,"formatCode":"General","autoWidth":true},"value":"Age","bold":true,"formatCode":"General","autoWidth":true}]
So it was easy to format. But since v0.5 , it takes data in Array of Array form like :
[["Name","age"],["Ashu","25"]
Can't figure out how to apply style in this new format.
This is the error I am getting when I am parsing a excel file
xlsx/xlsx.js:35
s = zip.file('docProps/core.xml').asText();
^
TypeError: Cannot call method 'asText' of null
at Context.xlsx (xlsx/xlsx.js:35:38)
at Object.module.exports.parse (D:\office work\projects\cricplayer_admin\nod
e_modules\node-xlsx\lib\node-xlsx.js:21:20)
at Object. (D:\office work\projects\cricplayer_admin\node-excel-t
ry.js:4:16)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Changing line 40 to:
val = val ? (isNaN(+val)?val:+val) : ''; // turn non-zero into number
will fix.
Hi,
Please could you update xlsx.js library from here and udpate npm package as well:
https://github.com/stephen-hardy/xlsx.js/blob/master/xlsx.js
There is several improvements/bugfixes for generation section..
hello,here is my test code:
var xlsx = require('node-xlsx');
var path = require('path');
var fs = require('fs');
//var obj = xlsx.parse(path.join(process.cwd(),'resources/history.xls')); // parses a file
var obj2 = xlsx.parse(fs.readFileSync(path.join(process.cwd(),'resources/history.xls'))); // parses a buffer
setInterval(function(){
console.log('');
},1000)
the latest version will add an undefined key to the data,but the version 0.5.1 won't.
build.js:667 ./~/xlsx/xlsx.js
Module not found: Error: Cannot resolve module 'fs' in D:\workSpace\git\vue-xlsx\node_modules\xlsx
It's wonderful to use your tool on Windows10! But today I got a TypeError when using centos7 with nodejs, this is the ErrorCode below. I hope you can fix it :) Thanks!
at Object.build (/root/projects/czg/node_modules/node-xlsx/lib/index.js:46:57) at repl:1:19 at REPLServer.self.eval (repl.js:110:21) at repl.js:249:20 at REPLServer.self.eval (repl.js:122:7) at Interface.<anonymous> (repl.js:239:12) at Interface.emit (events.js:95:17) at Interface._onLine (readline.js:203:10) at Interface._line (readline.js:532:8) at Interface._ttyWrite (readline.js:761:14)
I have a file with an empty row at the top. It gets ignored, so that the index of the .data
property doesn't match the work sheet.
v0.10.29 is fine
crash in node v0.10.31
In my xlsx file the data is Integer . but through the xlsx.parse method , the data change into a Float.
How can I resolve the problem?
My node-xlsx version "node-xlsx": "^0.7.4";
The origin data:
The code:
const workSheetsFromFile = xlsx.parse(
${__dirname}/../../${fileurl}); console.log(workSheetsFromFile[0].data);
The xlsx.parse data:
[ [ 'T(℃)', 'R(KΩ)' ],
[ -40, 3225.4617 ],
[ -39, 3026.3501 ],
[ -38, 2839.6504 ],
[ -37, 2664.7295 ],
[ -36, 2500.9521 ],
[ -35, 2347.6975 ],
[ -34, 2204.3501 ],
[ -33, 2070.3164 ],
[ -32, 1945.0251 ],
[ -31, 1827.9241 ],
[ -30, 1718.49 ],
[ -29, 1614.1907 ] ]
/Users/combine/epiboly/laiyehong/app/node_modules/node-xlsx/node_modules/xlsx/xlsx.js:11555
default: throw 'unrecognized type ' + val.t;
^
unrecognized type stub
i don't know below code's feature, but i explanatory them, parse can work.
switch(val.t){
case 'e': continue;
case 's': break;
case 'b': case 'n': break;
default: throw 'unrecognized type ' + val.t;
}
I try to use this package by npm install node-xlsx and the i import the package
import xlsx from 'node-xlsx';
but when i run the app it gives
Uncaught Error: Cannot find module 'jszip' install.js:78
then i install jszip by
import xlsx from 'jszip';
but it gives the same error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.