Git Product home page Git Product logo

sheetjs's Introduction

Important

Thank you Clippy!

But our Sheet is in another Workbook!

The new source repository URL is https://git.sheetjs.com/sheetjs/sheetjs. SheetJS CE remains truly open source under the Apache 2.0 License.

Issues should be raised at https://git.sheetjs.com/sheetjs/sheetjs/issues. Users can register directly or sign in with a valid GitHub account. Issues can also be raised at https://sheetjs.com/chat.

Documentation is available at https://docs.sheetjs.com.

Scripts and NodeJS modules are available at https://cdn.sheetjs.com.

The master branch branch of the SheetJS/sheetjs repository on GitHub includes all commits through 515d1c6f2e1d3ca422ee9198b177cfd926434936.

The SheetJS Community Edition offers battle-tested open-source solutions for extracting useful data from almost any complex spreadsheet and generating new spreadsheets that will work with legacy and modern software alike.

SheetJS Pro offers solutions beyond data processing: Edit complex templates with ease; let out your inner Picasso with styling; make custom sheets with images/graphs/PivotTables; evaluate formula expressions and port calculations to web apps; automate common spreadsheet tasks, and much more!

Note

๐Ÿ’ผ We're Hiring!

SheetJS is looking for US-based software developers to expand this project and related software libraries and tools. https://sheetjs.com/careers more info.

Resources

License

Please consult the attached LICENSE file for details. All rights not explicitly granted by the Apache 2.0 License are reserved by the Original Author.

sheetjs's People

Contributors

0xc0der avatar dman577 avatar dxcx avatar garrettluu avatar hmalphettes avatar ingfraga avatar jefleponot avatar jimmywarting avatar kawanet avatar mior avatar morgan-sam avatar nathanathan avatar notchris avatar phaseone avatar reviewher avatar robbannn avatar rohandhamapurkar avatar rohankulshreshtha avatar ryancavanaugh avatar sandersn avatar sebastianmetzger avatar sebmaster avatar sheetjsdev avatar srijonsaha avatar theskillwithin avatar thibautsf avatar tmburnell avatar vvaldersteins avatar wlawt avatar wolfgang42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sheetjs's Issues

Disappearing column

In this workbook, the "group" column on the "tags" sheet is left out of the JSON output. The workbook was generated by gdocs. Strangely, editing the workbook file in MS Excel makes the group column appear in the output.

Use of console.error instead of throw

There are a 2 instances, where console.error is used instead of throw. I just noticed in the tests for the file with the encoded filename xlsx.js#L643 will be executed.

How severe is the error? If it's not severe: IE 6 (prob. higher too) doesn't support console(.error) AFAIK so that would throw an exception and be unuseable.
If it's severe, the user should know about it. I'd suggest euther return it in the result, or with a throw.

Merged cell handling

First, thank you for this library. Second, if I'm in the wrong place to be asking questions, I apologize.

I'm working with documents that contain merged cells. I'd like to iterate over rows and for a particular cell grab the value in a column header above it. The column headers are in merged cells.

Based on the demo, the sheet.xml files, and relevant sections of the spec (29500-1 SS 18.3.1.55 and A.2 ln. 2293 through ln. 2298), it seems the merge cell value is always in the top left cell and subsequent cells in the merge range are undefined.

Are there any helper attributes on the JS object of a merged cell (obj.mergeValue or obj.isMergeCell) or is that something I'll have to handle myself?

Cheers and thank you for your time! ๐Ÿป

Converting sheets to arrays of objects doesn't work

in xlsx.js:335 there's a small error:

function sheet_to_row_object_array(sheet){
    var val, rowObject, range, columnHeaders, emptyRow, C;
    var outSheet = [];
    if (sheet["!ref"]) {
        range = XLSX.utils.decode_range(sheet["!ref"]);
                // XLSX.utils is undefined
                // it should be just utils.decode_range, I suppose

XLSX object is not necessary here (it's in method scope anyway).
(I wanted to send you a pull request but my laptop's battery is empty and I'm writing from an iPad).

sheet_to_row_object_array(sheet) crashes when looping through sheetnames

The following code crashes

var XLSX = require('xlsx')
var xlsx = XLSX.readFile('test.xlsx')

xlsx.SheetNames.forEach(function(sheetName) {

  // this works if sheetname is given:
  // var parsedSheet = XLSX.utils.sheet_to_row_object_array(xlsx.Sheets["3AU"])

// this crashes:
  var parsedSheet = XLSX.utils.sheet_to_row_object_array(xlsx.Sheets[sheetName])

  console.log(parsedSheet)

})

C:\IS\node\node_modules\xlsx\xlsx.js:338
if (sheet["!ref"]) {
^
TypeError: Cannot read property '!ref' of undefined
at Object.sheet_to_row_object_array (C:\IS\node\node_modules\xlsx\xlsx.js:338:11)
at C:\IS\node\testapp\app3.js:9:32
at Array.forEach (native)
at Object. (C:\IS\node\testapp\app3.js:5:17)
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)

Replace JSZip

JSZip doesn't support large files very well (try A1=1,A2=A1+1,...,A1000000=A999999+1)

Issue with custom formats containing '"' (Literal Text)

I began testing your awesome library against a set of excel files that I am working with for a project, and found that I had a few that would case the browser to hang.

The custom format string is: "$"#,##0.00;("$"#,##0.00)

The problem seems to be in eval_fmt() in case '"'.

The script gets caught in the for loop in there infinitely, with the index var getting incremented far beyond the length of the fmt string, until the browser has deemed the script is hung and kills it.

Can Base64 conversion be handled within the code?

Thanks for the Update on IE10, One more suggestion is to handle the Base64 conversion with in the code. Currently you have given an option to paste the Base64 string, can this be dynamically generated via the code accessing the variable "f" in the below code snippet?

function b64it(xlsxFile) {

    var xlsx = XLSX.readFile(xlsxFile, {type: 'file'});//<--How the base64 conversion should be handled
    process_xlsx(xlsx);
}

function handleDrop(e) {
    e.stopPropagation();
    e.preventDefault();
    var files = e.dataTransfer.files;
    var i,f;
    for (i = 0, f = files[i]; i != files.length; ++i) {
    b64it(f);//<-- f represents one of the files in the List

    /*
        var reader = new FileReader();
        var name = f.name;
        reader.onload = function(e) {
            var data = e.target.result;
            //var xlsx = XLSX.read(data, {type: 'binary'});
            var arr = String.fromCharCode.apply(null, new Uint8Array(data));
            var xlsx = XLSX.read(btoa(arr), {type: 'base64'});
            process_xlsx(xlsx);
        };
        //reader.readAsBinaryString(f);
        reader.readAsArrayBuffer(f);
    */  

    }//for

}//handleDrop

stephen-hardy / xlsx.js enhancements

Hi Niggler. I found your work on xlsx file thanks to license discussion on stephen-hardy implementation. I'm one of those persons just too lazy to read license files.
I needed to write Excel files to export data from my webpage and I found his code on GitHub. I forked his work and added support for cell styling, to be able to change fonts, borders, colors, etc., and I rewrote almost every line of his export code to make it dinamically created (his version has fixed parameters). I wanted to share my code but found this licensing problem with his code and I need to know how can I proceed. Can you give me an advise on this matter?
Thanks!

read error: expected address at parse_PropertySet

I have a particular xls file type that I need to parse. All of these methods below work fine with simple xls files, but for mine they all fail.

var s = 3;
var file = 'C:/<path to my file>.xls', wb;
    if(s===0) {
        file = fs.readFileSync(file);
        wb = xlsjs.read(file, {type: 'binary'});
    }else if(s===1) {
        wb = xlsjs.readFile(file);  
    }else if(s===2) {
        fs.readFile(file, 'binary', function(err, data) {
            if (!err) {
                wb=xlsjs.read(data.toString('base64'),{type:'base64'});
            }
        });
    }else if(s===3) {
        fs.readFile(file, 'base64', function(err, data) {
            if (!err) {
                wb=xlsjs.read(data,{type:'base64'});
            }
        });
    }

For s = 0, 1 the error is:
Error: Read Error: Expected address 483 at 463 :3 at parse_PropertySet
(C:....\node_modules\xlsjs\xls.js:620:36)'

For s = 2 the error is in xls.js:154:
if(m !- hexstr) throw (fld||"") + 'Expexted ' + hexstr + ' saw ' + m;
^
Header SignateL Expected d0cf11e0a1b11ae1 saw 149fbfd35db7e39e

For s = 3 the error is in xls:620
if(blob.1 !== props[i][1] throw new Error("Read Error: Expected address " + ..
Error: Read Error: Expected address 483 at 463 :3

Any solutions? Is it my xls file?

Uncaught TypeError: Cannot call method 'getTypeOf' of undefined

<script lang="javascript" src="C:/Users/003347/Desktop/jszip.js"></script>
<script lang="javascript" src="C:/Users/003347/Desktop/xlsx.js"></script>
<script lang="javascript" src="C:/Users/003347/Desktop/jszip-load.js"></script>
<script lang="javascript" src="C:/Users/003347/Desktop/jszip-inflate.js"></script>
<script lang="javascript" src="C:/Users/003347/Desktop/jszip-deflate.js"></script>

function getXLSX(readFile) {

              var reader = new FileReader();

              // Read file into memory as UTF-16      
              reader.readAsArrayBuffer(readFile);

              // Handle progress, success, and errors                
              reader.onload = loaded;
            }


 function loaded(evt) {   
  var data = evt.target.result;
  //var xlsx = XLSX.read(data, {type: 'binary'});
  var arr = String.fromCharCode.apply(null, new Uint8Array(data));
 var xlsx = XLSX.read(btoa(arr), {type: 'base64'});
  process_xlsx(xlsx);
             }

function process_xlsx(xlsx) {
var output = "";

output = to_csv(xlsx);

if(out.innerText === undefined) out.textContent = output;
else out.innerText = output;
}

function to_csv(workbook) {
var result = [];
workbook.SheetNames.forEach(function(sheetName) {
var rObjArr = XLSX.utils.sheet_to_csv(workbook.Sheets[sheetName]);
if(rObjArr.length > 0){
result.push("SHEET: " + sheetName);
result.push("");
result.push(rObjArr);
}
});
return result.join("\n");
}

while reading with 'readAsBinaryString' xlsx file that consists of numbers i got "Uncaught TypeError: Cannot call method 'getTypeOf' of undefined"
when reading with 'readAsArrayBuffer' this time i got 'Uncaught TypeError: Cannot call method 'decode' of undefined '.Could you please help me what should we import and how should code be whille reading XLSX?i try many version of this link http://www.javascriptoo.com/js-xlsx but doesn't work

Long text (sentences) in single cell throws AssertionError

Hi, I've found the AssertionError being thrown when I tried to parse a bit large excel file.
And narrowed it down to single cause: where if the excel file has a cell that holds large text (sentences), it throws the error.

Here's AssertionError:

AssertionError: Trying to read beyond buffer length
    at Buffer.readUInt8 (buffer.js:592:12)
    at Buffer.ReadShift (path/to/test/node_modules/xlsjs/xls.js:146:35)
    at parse_XLUnicodeRichExtendedString (path/to/test/node_modules/xlsjs/xls.js:1052:28)
    at Object.parse_SST [as f] (path/to/test/node_modules/xlsjs/xls.js:1214:13)
    at slurp (path/to/test/node_modules/xlsjs/xls.js:4046:11)
    at parse_workbook (path/to/test/node_modules/xlsjs/xls.js:4099:15)
    at parse_xlscfb (path/to/test/node_modules/xlsjs/xls.js:4389:26)
    at Object.readFile (path/to/test/node_modules/xlsjs/xls.js:4499:37)
    at Object.<anonymous> (path/to/test/parse.js:3:18)
    at Module._compile (module.js:449:26)

Here's the zip of excel files that works and that doesn't.

Here's how I used it on my node test.

var xls = require('xlsjs');
var result = xls.readFile('data/raw/demo-work.xls')
// var result = xls.readFile('data/raw/demo-doesnt-work.xls')=> throws the error.
console.log( result )

Would be awesome if you have some time to look into it :)

XML namespacing

Hi,

I've noticed another small, but nasty bug:

Every cell with xml attributes gets ignored because of regular expressions. Try to compare your current results with this quick fix:

// file: xlsx.js :143
function parseStrs(data) { 

    // XXX: improve, temporary fix
    data = data.replace(/ xml:space="preserve"/gi, '');

    var s = [];
    var sst = data.match(new RegExp("<sst ([^>]*)>([\\s\\S]*)<\/sst>","m"));
    if(sst) {
        s = sst[2].replace(/<si>/g,"").split(/<\/si>/).map(function(x) { var z = {};
            var y=x.match(/<(.*)>([\s\S]*)<\/.*/); if(y) z[y[1]]=unescapexml(y[2]); return z;});

        sst = parsexmltag(sst[1]); s.count = sst.count; s.uniqueCount = sst.uniqueCount;
    }
    if(debug) s.rawdata = data;
    return s;
}

I had to fix that quickly because the bug had some pretty serious influence on the app I was presenting today. Sorry for pointing out an error with no comprehensive solution, but I have no time to fix that in a more appropriate way now and I thought you'll want to know that before. I'll be able to post a better solution along with a pull request in the next week.

By the way, great job. The library still needs some improvements but compared to others - is pretty darn fast :)

Error: Corrupted zip : can't find end of central directory

EDIT: if you encounter this issue, confirm you are using the latest version and that you are using the correct input type! See https://github.com/sheetjs/sheetjs#input-type

For example, using a FileReader with readAsArrayBuffer will call the load event where the result is an ArrayBuffer, so type should be "array"

If data is received through an XHR or fetch, verify that the source data is not UTF8-encoded. Some platforms like AWS Gateway API do this automatically and require an override as explained in the function demo

--

I am trying to use this library to parse a base64 encoded .xslx file on the server using node.js. I have also removing the base64 header info and loading the data into a binary buffer, but I get the same error.

Here is my function to parse the file:

var parseFile = function(data){
  var xlsx = XLSX.read(data, {type: 'base64'});
  var sheet_name_list = xlsx.SheetNames;
  xlsx.SheetNames.forEach(function(y) {
    for (z in xlsx.Sheets[y]) {
      if(z[0] === '!') continue;
      console.log(y + "!" + z + "=" + JSON.stringify(xlsx.Sheets[y][z].v));
    }
  });
};

However, when I try to parse the data, I get the following error.

Error: Corrupted zip : can't find end of central directory
        at Object.ZipEntries.readEndOfCentral (/Users/.../node_modules/xlsx/jszip.js:2087:27)
        at Object.ZipEntries.load (/Users/.../node_modules/xlsx/jszip.js:2104:18)
        at Object.ZipEntries (/Users/.../node_modules/xlsx/jszip.js:2010:18)
        at Object.JSZip.load (/Users/.../node_modules/xlsx/jszip.js:2115:22)
        at Object.JSZip (/Users/.../node_modules/xlsx/jszip.js:5:14)
        at Object.readSync [as read] (/Users/.../node_modules/xlsx/xlsx.js:940:24)
        at parseFile (/Users/.../routes/tickets.js:35:19)

any thoughts as to why this might be happening? When I load my file into your demo site, it parses it to json just fine.

Workbooks exported from web app cannot be parsed

XLS workbook exported from a web app (I am not sure which library they are using on the back end, have an inquiry in to find that out) fails to parse with errors such as

xls.js:212 Uncaught Header Signature: Expected d0cf11e0a1b11ae1 saw 3c3f786d6c207665

Opening and re-saving the file in Excel appears to correct the issue, so I suspect the original generating library is doing something wrong.. if it is possible to support though that would be ideal.

Possible to use a file which is retrieved from server using javascript?

I have tried to use xmlhttprequest to download a file, then use all variations of the type option in CFB.read(data, type:{"*"}).

I've also tried setting responsetype / overideMimeType etc on the xmlhttprequest ... unfortunately, the file always seems to use an encoding which isn't compatible with the CFB reader.

Wondering if this is something you have considered?

Password-protected files

They actually fall back to the CFB container, which is probably why google drive pukes and most parsers die

last column of spreadsheet is lost if first column is blank

Two bugs in parseSheet():

(1) the dimension test logic always fails, so the sheet dimension is never set.

(2) the column-index logic in parseSheet() is wrong -- it assumes one-based, but the cells.forEach() uses zero-based, so the -1 corrections are not appropriate.

Patch:

diff -r ac083a41a811 xlsxconverter/WebContent/js-xlsx/xlsx.js
--- a/xlsxconverter/WebContent/js-xlsx/xlsx.js  Mon Oct 28 12:42:35 2013 -0700
+++ b/xlsxconverter/WebContent/js-xlsx/xlsx.js  Mon Oct 28 12:44:41 2013 -0700
@@ -533,7 +533,7 @@

    /* 18.3.1.35 dimension CT_SheetDimension ? */
    var ref = data.match(/<dimension ref="([^"]*)"\s*\/>/);
-   if(ref && ref.indexOf(":") !== -1) s["!ref"] = ref[1];
+   if(ref && ref.length == 2 && ref[1].indexOf(":") !== -1) s["!ref"] = ref[1];

    var refguess = {s: {r:1000000, c:1000000}, e: {r:0, c:0} };
    var q = ["v","f"];
@@ -552,8 +552,9 @@
        var cells = x.substr(x.indexOf('>')+1).split(/<c/);
        cells.forEach(function(c, idx) { if(c === "" || c.trim() === "") return;
            c = "<c" + c;
-           if(refguess.s.c > idx - 1) refguess.s.c = idx - 1;
-           if(refguess.e.c < idx - 1) refguess.e.c = idx - 1;
+           // idx is already zero-based
+           if(refguess.s.c > idx) refguess.s.c = idx;
+           if(refguess.e.c < idx) refguess.e.c = idx;
            var cell = parsexmltag((c.match(/<c[^>]*>/)||[c])[0]); delete cell[0];
            var d = c.substr(c.indexOf('>')+1);
            var p = {};
@@ -600,7 +601,8 @@
            s[cell.r] = p;
        });
    });
-   if(!s["!ref"]) s["!ref"] = encode_range(refguess);
+   var rguess = encode_range(refguess);
+   if(!s["!ref"]) s["!ref"] = rguess;
    return s;
 }

FATAL ERROR: JS Allocation failed - process out of memory

With a spreadsheet in LibreOffice Calc on Ubuntu (Version: 4.1.2.3), Node.JS v0.8.25 and XLSX 0.3.3.

One case seems to lead tothe processing loop staying stuck forever until Node.JS rans out of memory:

FATAL ERROR: JS Allocation failed - process out of memory

This is the output when breaking in the debugger (probably just random point in the while loop):

break in node_modules/xlsx/xlsx.js:156
 154        switch((c = fmt[i])) {
 155            case '"': /* Literal text */
 156                for(o="";fmt[++i] !== '"';) o += fmt[(fmt[i] === '\\' ? ++i : i)];
 157                out.push({t:'t', v:o}); break;
 158            case '\\': out.push({t:'t', v:fmt[++i]}); ++i; break;

...sadly, while I trying to create a reduce set of the problematic spreadsheet I apparently made some changes to the original and it started working again...

I'm thinking LibreOffice Calc creates some strange XLSX sometimes. The problem seemed to start after adding boolean values.

You can close this for now as I don't have a sample, but if I encounter the problem again (or someone else does) I'll come back to this.

License and merging with js-xlsx

Hi, I have a couple questions about why you're maintaining separate libraries for xls and xlsx files, and the legal warning in the license section of the readme. As a point of reference, the python xlrd library reads xls and xlsx files, and does not as far as I can tell, warn users to consult a lawyer for commercial use. In your opinion, would the legal risks of using this library be any different from those of using xlrd?

Some older browsers cook binary data

Ran into a problem where I was getting unexpected header signature errors when running some unit tests through PhantomJS, but the same tests would work fine in Chrome and Firefox. It turns out that the AJAX methods I was using to read the file were cooking the binary data, per Receiving binary data in older browsers.

I applied the recommended fix, overriding the charset, and it was closer, but the string still had garbage in the high-order bytes. The next step in the fix is to charCodeAt(x) & 0xff, which I applied to your s2a function:

var w = s.split("").map(function(x){return x.charCodeAt(0) & 0xff;});

That fixed my issue in PhantomJS, and continued to work in Firefox and Chrome.

I can make a pull request if you like, but I admit that I'm clueless as to the wider repercussions of the change.

hebrew encoding

hi, when using hebrew chars in the xlsx sheet the output comes with question marks instead of hebrew chars. how can i overcome this?

Binary parsing error

Hello,

I would like to tell you that I really like your excel libraries. I have used js-xlsx with success and I can parse xlsx files from binary data. However I can not parse xls binary data. I keep getting the following error, even with simple files that hold 1 row with 2 cells:

TypeError: Object 9,8,16,0,0,6,5,0,102,50,205,7,193,128,1,0,6,6,0,0,225,0,2,0,17
6,4,193,0,2,0,0,0,226,0,0,0,92,0,112,0,5,0,0,75,101,118,105,110,32,32,32,32,32,3
2,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,3
2,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,66,0,2,0,176,4,97,1,2,0,
0,0,192,1,0,0,61,1,6,0,1,0,2,0,3,0,156,0,2,0,17,0,25,0,2,0,0,0,18,0,2,0,0,0,19,0
,2,0,0,0,175,1,2,0,0,0,188,1,2,0,0,0,61,0,18,0,240,0,135,0,147,78,74,31,56,0,0,0
,0,0,1,0,88,2,64,0,2,0,0,0,141,0,2,0,0,0,34,0,2,0,0,0,14,0,2,0,1,0,183,1,2,0,0,0
,218,0,2,0,0,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,66,7,1,67,0,97,0,108,0,10
5,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,66,7,1,67,0,97,0,10
8,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,66,7,1,67,0,9
7,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,66,7,1,
67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,6
6,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,104,1,1,0,56,0,188,2,0,0,
0,2,0,66,7,1,67,0,97,0,109,0,98,0,114,0,105,0,97,0,49,0,30,0,44,1,1,0,56,0,188,2
,0,0,0,2,0,66,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0 has no method 'cop
y'
at Function.Buffer.concat (buffer.js:496:9)
at Array.Buffers.toBuffer (C:\fakepath\lib\xls.js:909:19)
at parse (C:\fakepath\lib\xls.js:795:54)
at Object.readSync as read
..

The code I am using:

var xls = require('./xls.js');
xls.read(file.data, { type: 'binary' }); // file.data is binary data of the xls file

Any idea why this is happening?

Thanks

IE10 Support (reader.readAsBinaryString)

I have trouble reading the Uploaded File (XLSX) via FileReader API's "readAsBinaryString" method in IE10. "readAsText" method works fine. Has anyone come across this, does IE support this method? Am I missing something. Pls find the snippet below:

function handleFileUpload(evt){

    evt.stopPropagation();
    evt.preventDefault();

    var files = (evt.target.files || evt.dataTransfer.files);
    var output = [];

    for (var i = 0, f; f = files[i]; i++) { 
        output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ', f.size, '   bytes, last modified: ', f.lastModifiedDate ?                                   
        f.lastModifiedDate.toLocaleDateString() :   'n/a', '</li>');

        var reader = new FileReader();
        reader.onload = function(e) {
            var data = e.target.result;
            alert("-- Data Length --" + data.length);
    };

         // Read in the XLSX file in Binary Mode.   
         //reader.readAsBinaryString(f);//<-- does not work if this method is used in IE10 (10.0.9200.16540C0), but works on Chrome     
           reader.readAsText(f);//<-- Works on both Chrome & IE10 (10.0.9200.16540C0)

    }//for 

}//handleFileUpload

[WRONG LIBRARY] Formula causes NaN

Looks like ANY formula causes a NaN value no matter what format is used.

Cell Formula: =REPLACE(REPLACE(H8,1,26,""),11,100,"")
Cell Computed Value: 2f2a2ffa15

When formatted as "General":
{ value: NaN, formatCode: 'General' }

When formatted as "Text":
{ value: NaN, formatCode: '@' }

Cell Value: Test works fine.
{ value: 'ID', formatCode: 'General' }

Code used:

var xlsx = require('node-xlsx');
var contents = xlsx.parse('pf_pages.xlsx');
var rows = contents.worksheets[0].data;

for (var i=0; i<=rows.length; i++) {
    var row = rows[i];
    try {
        console.log(row[9]);
    } catch(e) {}
}

Node Version: v0.10.12
npm ls:

โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”€ [email protected]
โ”œโ”€โ”€ [email protected]

No errors
OSX 10.8.4
Excel of Mac 2011 v.14.0.0 (100825)

Uncaught TypeError: Cannot read property 'length' of undefined

This is a much needed project.

The bug occurs due to val.XF.ifmt being 166. I get this value when I format a column using MS Excel to 'dd-mmm-yy' format. Also it seems when ifmt >= 0x00A4 the number format is not a built-in number format [1]

So is there a way to extract this custom number format (referred by ifmt = 166 in this case), which should be somewhere in the excel file, and fix this bug properly?

[1] - http://msdn.microsoft.com/en-us/library/dd948560(v=office.12).aspx

Find the stack trace below.

Uncaught TypeError: Cannot read property 'length' of undefined xls.js:581
choose_fmt xls.js:581
format xls.js:596
sheet_to_csv xls.js:5030
(anonymous function) (index):68
to_csv (index):67
process_wb (index):108
worker.onmessage (index):39

screen shot 2014-01-08 at 12 38 30 pm

the numbers are going wild

I have a row with some numbers. The small ones (1250 for instance) are doing well ; but when they are a little bigger, they are converted in a kind of scientific notation (but not exactly).

For instance, 1200455 become 2.811376202761008e-307.

Is there a way to come back from that ? Even in post treatment ?

Off-by-one error for Number cells

In the spreadsheets I'm testing against, I think I found an off-by-one error in parse_workbook:

case 'Number': {
  addline({c:val.c + range.s.c, r:val.r + range.s.r}, {v:val.val, t:'n'});
} break;

For this workbook, range.s.c and .r are both 1. This was shifting the rows and columns down by one, which would then get overwritten by a later cell. The symptom that led to my investigation was seemingly-missing data in the sheet.

So I went in with a flamethrower and changed it to:

case 'Number': {
  addline({c:val.c, r:val.r}, {v:val.val, t:'n'});
} break;

This fixed my issue. I figure that range offset was in there for a reason, but something about it seems hinky.

Uncaught RangeError: Maximum call stack size exceeded

I have a rather big spreadsheet. 1MB with almost 15,000 rows.

Importing it will give me this "Maximum call stack size exceeded" error.
I tried and noticed that the error no longer occurs when the rows are reduced to 1,000.

Is there a solution? :)

Date support

I created a simple spreadsheet with a few dates in a few of the cells (ie, "12/01/2012"). It looks like the value (cell.v param) returns a number (it appears to be the number of days since 1/1/1900). Is there anyway that xlsx.js could do this date conversion automatically so that cell.v returns a date string? I know there is date formatting, etc, but even if it's just a M/D/Y date string, that would be great. In the raw sheet xml there is a "s=1" on all of my date cells.

This library is great, BTW - thanks for your work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.