The SheetJS Community Edition offers battle-tested open-source solution

Overview

SheetJS

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!

License Build Status Snyk Vulnerabilities npm Downloads GitHub Repo stars

Analytics

Build Status

Documentation

Related Projects

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.

Comments
  • Writing Style information into Excel

    Writing Style information into Excel

    I am trying to preserve the style information while I read and then write an excel File. Seems like the style information is read when I read the file, but unfortunately when I write the file its not preserved.

    Thoughts on how I can read and write the style information?

                excelFile = XLSX.readFile(file.path, {
                    cellStyles: true
                });
    
                // some processing here!
    
                XLSX.writeFile(excelFile, fileName, {
                    cellStyles: true
                });
    

    @sheetjs After a conversation with @elad (https://github.com/hubba/js-xlsx/commit/5e9bca78f2b0c54242cefc8a358f3151232941ab#commitcomment-8039333) I was informed that the styling information is only read, and not written back to excel.

    Style 
    opened by nukulb 167
  • Doesn't work with browserify or webpack.

    Doesn't work with browserify or webpack.

    EDIT: please raise a new issue if you encounter build issues with browserify, webpack, requirejs, systemjs, or any other module bundler or loader or packaging system.

    In webpack I get this error:

    ERROR in ../~/xlsx/xlsx.js
    Module not found: Error: Cannot resolve module 'fs' in /Users/Ram/Desktop/bob/node_modules/xlsx
     @ ../~/xlsx/xlsx.js 32:3635-3648 33:3206-3224
    
    ERROR in ../~/xlsx/ods.js
    Module not found: Error: Cannot resolve module 'fs' in /Users/Ram/Desktop/bob/node_modules/xlsx
     @ ../~/xlsx/ods.js 67:9-27
    
    ERROR in ../~/xlsx/dist/cpexcel.js
    Module not found: Error: Cannot resolve 'file' or 'directory' ./cptable in /Users/Ram/Desktop/bob/node_modules/xlsx/dist
     @ ../~/xlsx/dist/cpexcel.js 1:165488-165513
    
    opened by quadrupleslap 55
  • sheet_to_json skips empty rows

    sheet_to_json skips empty rows

    When calling xlsx.utils.sheet_to_json(sheet, {header: 1}) I would expect to receive an array of arrays including empty rows. However the function explicitly skips out empty rows which makes it impossible to select a particular row in the results. It would be good to make this behaviour configurable.

    As a workaround, I have used sheet_to_csv, which doesn't skip rows, followed by csv-parse.

    opened by tamlyn 42
  • Date cells

    Date cells

    Excel supports cells that display formatted dates. For testing purposes I created a file with only one cell (A1) and entered the value 2014-09-28. The value was immediately formatted as a date and displayed as 9/28/14.

    I wanted to see how I can reliably extract back the original date. I used the following program:

    var xlsx = require('xlsx');
    
    var workbook = xlsx.readFile(process.argv[2]);
    for (var i = 0; i < workbook.SheetNames.length; i++){
        var worksheet = workbook.Sheets[workbook.SheetNames[i]];
        console.log(worksheet);
    }
    

    And got the following output (after running it with node myfile.xlsx);

    { A1: { t: 'n', v: 41910, w: '9/28/14' }, '!ref': 'A1' }
    {}
    {}
    

    I see several problems here:

    • The number 41910 is the number of days from some epoch, either 1900 or 1904, depending on where the file was created (Windows or Mac). There should be a way to tell how to treat this value.
    • The t field (for type) indicates this is a number. Can it instead indicate it's a date? or should there be a different property?
    • There's no way to retrieve the actual value that was entered - 2014-09-28 - so the original date, along with a reliable way of retrieving it, seems to be lost.

    All of the above also applies for time fields.

    Am I missing something? Is there a way to reliably get 2014-09-28 from the cell data?

    opened by elad 40
  • Error: Corrupted zip : can't find end of central directory

    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.

    opened by remotevision 38
  • Template Filling, Styles & Page Setups

    Template Filling, Styles & Page Setups

    I am trying to replace an implementation of PHPExcel with js-xlsx under node js as I am no longer using php server-side.

    I have a series of excel templates that are pre-formatted with colours and styling, and also page size, margins, print areas etc etc, and then I simply add text to the relevant cells, under PHPexcel it works very well.

    I discovered js-xlsx a few hours ago and thought I had found the solution, but it appears that I am unable to duplicate the original file, only with the cell values changed, whilst maintaining everything else in the original file.

    var XLSX = require('xlsx');
    var wb = XLSX.readFile('/usr/share/nodejs/dwap/public/xls/qplan.xlsx',{cellStyles:true});
    XLSX.writeFile(wb,'/usr/share/nodejs/dwap/public/xls/out.xlsx',{bookSST:true});
    

    I have used the simple code above to read in a formatted file and then save it again, but all of the styling is lost.

    Is it possible to achieve this kind of functionality with js-xlsx and if so what am I doing wrong ?

    Style Operations 
    opened by diginfo 33
  • xls => json => manipulation => xlsx

    xls => json => manipulation => xlsx

    So, I've been digging around this repo a bit and it seems like the go-to method for filtering etc is to convert things to json using XLSX.utils.sheet_to_json(wb.Sheets.SheetName), however I can't find any documentation on then turning that manipulated json back into a workbook. Please advise! (thanks in advance)

    Operations 
    opened by reidblomquist 29
  • Corrupt XLSX file after downloading

    Corrupt XLSX file after downloading

    Hi, I know there is already a very similar issue here but it does not provide a solution, because the author of this issue just uses a different approach to download the file in the end. https://github.com/SheetJS/js-xlsx/issues/122

    I'm trying to download a file which is generated in the nodejs backend from the angular frontend, but when I try to open it, it's always corrupted. Of course I have seen the example in the readme of this project and tried it, but it also came out corrupted. I can write the output to a file and then point the browser to it by using window.location() and the file is fine. Sadly I could not get this approach working with my authorization code. I read somewhere that it's better to send buffer objects when working with expressjs, so here is my code right now:

    // Backend
    var wopts = { bookType:'xlsx', bookSST:false, type:'buffer' };
    
            var wbout = XLSX.write(workbook,wopts);
    
            res.writeHead(200, [['Content-Type',  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']]);
            res.end( wbout );
    
    // Frontend
    // This triggers the backend function:
     $http.get("/abrechnung/exportToExcel/" + JSON.stringify(pageAndFilter.filterByFields)).
                 success(function(data, status, headers, config) {  
                  // The data object is the buffer
            saveAs(new Blob([data],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}), "test.xlsx");
            }).
      error(function(data, status, headers, config) {
      });
    
    

    Any help would be greatly appreciated!

    opened by nikolaifischer 27
  • how client download xlsx file

    how client download xlsx file

    My node.js code var file = fs.readFileSync('./report/output/out.xlsx', 'binary'); res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); res.setHeader('Content-Disposition', "attachment; filename=" + "out.xlsx") return res.end(file, 'binary'); How javascript client download this file ? I have try many way but get open file corrupt Thanks for help

    opened by nvcken 26
  • cpexcel.js problem

    cpexcel.js problem

    Hi! I try use js-xlsx, bower and glup, but when I added 2 files to my progect

    require('../vendors/js-xlsx/dist/jszip.js'); require('../vendors/js-xlsx/xlsx.js');

    I got this error

    { [Error: module "./cptable" not found from "F:.......\vendors\js-xlsx\dist\cpexcel.js"] plugin: 'gulp-browserify', showStack: undefined, name: 'Error', message: 'module "./cptable" not found from "F:\.......\vendors\js-xlsx\dist\cpexcel.js"', fileName: undefined, lineNumber: undefined

    I have cpexcel.js file in 'dist' folder. Any idia how I can fix it? Thanks!

    opened by volodymyrl 26
  • export xls with a image

    export xls with a image

    Hi does this library allow me to export a xls with a image somewhere on the sheet? if there are any jsfiddles on the web showing this it would also be great.. thanks

    Images Features 
    opened by oreillyj1 25
  • fix: getTimeZoneOffset needs to return a double instead of integer at v8

    fix: getTimeZoneOffset needs to return a double instead of integer at v8

    I found that the return time of the datenum method in Chrome browser is incorrect, consider customizing a getTimeZoneOffset function to fix Date.prototype.getTimezoneOffset() return error value

    opened by queguangwei 2
  • Rearranging the XLSX.write order

    Rearranging the XLSX.write order

    Hi is it possible to write the output to the excel file as shown below? Have the headers in one column (A1) and data in another (B1).

    image

    Rather than the normal behavior as shown below image

    opened by Harsha192 0
  • format entire column

    format entire column

    This is more of a question. I have scoured the internet trying to find out if there is a way to format an entire column as text. My "source" sheet has the entire column formatted as text but only the header row is text when I download/save it. The source file is just a "template" with only the header row having values. Rest are blank rows.

    this is all I am doing in my code example (result is an arrayBuffer coming from the .NET webapi)

    this.carrierRatesService.getCarrierRatesFileTemplate()
          .subscribe(result => {
            if (result.byteLength > 0) {
              const wb = xlsx.read(result, { type: 'buffer', cellStyles: true });
              const fileName = 'CarrierRatesTemplate.xlsx';
              xlsx.writeFile(wb, fileName)
            }})
    

    This is the source file (7th row showing as Text datatype) image

    This is the result of my download (7th row as General datatype) image

    Is there a way to set an entire column manually? It is causing leading 0's to be cut off.

    opened by slymuffhugger 2
  • [Tips] How to test downloaded Excel file from response

    [Tips] How to test downloaded Excel file from response

    Gist to test the content of an Excel File in a controller (e2e) test, with a lib like supertest:

      function binaryParser(res, callback) {
        res.setEncoding('binary')
        res.data = ''
        res.on('data', function (chunk) {
          res.data += chunk
        })
        res.on('end', function () {
          callback(null, new Buffer(res.data, 'binary'))
        })
      }
    
      describe('exports/:id (GET)', () => {
        it('should return an excel File', async () => {
          const res = await request(app.getHttpServer())
            .get('/exports/xxx')
            .expect('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8')
            .buffer()
            .parse(binaryParser)
    
          assert.ok(Buffer.isBuffer(res.body))
    
          const workbook = XLSX.read(res.body, { type: 'buffer' })
          const sheet = workbook.Sheets[workbook.SheetNames[0]]
          const json = XLSX.utils.sheet_to_json(sheet, { header: 1 })
    
          expect(json).toEqual([
            ['My first Row', 'My second Row'],
            ['val 1', 50],
            ['val 2', 10]
          ])
        })
      })
    
    opened by pleymor 2
Owner
SheetJS
Truly Open Source Data Tools and Miscellany
SheetJS
🚀 Battle-tested Next.js TypeScript Prisma template with an opinionated architecture. 🔋 Included ™️

?? The Ultimate Next.js Starter Pack Next.js ^12 + TypeScript + Prisma + Chakra UI starter packed with useful development features. I've adopted indus

Nam 7 Dec 10, 2022
A community website built by the community for the community (Hacktoberfest 2022) :tada:

Hacktoberfest 2022 ?? : Built by the community for the community! This repository is an initiative which aims to help beginners kickstart their open-s

Your First Open Source Project 5 Oct 12, 2022
Code Scanning/SAST/Static Analysis/Linting using many tools/Scanners with One Report - Scanmycode Community Edition (CE)

Star it If you like it, please give it a GitHub star/fork/contribute. This will ensure continous development ⭐ TLDR; To install it. Install docker and

Marcin Kozlowski 351 Dec 29, 2022
A community contributed game system for Pathfinder Second Edition.

The Official Pathfinder Second Edition Game System for FoundryVTT This system uses trademarks and/or copyrights owned by Paizo Inc., which are used wi

Foundry Virtual Tabletop 104 Jan 5, 2023
microregex is an open source and highly curated catalog of regular expression patterns. It offers programmers RegEx snippets that can be quickly exported into a variety of programming languages and distributed around teams.

microregex - A catalog of RegEx patterns View Demo · Report Bug · Request Feature Loved the tool? Please consider contributing ✍️ to help it improve!

Sunit Shirke 4 Oct 25, 2022
Fullstack Dynamic NFT Mini Game built using 💎 Diamond Standard [EIP 2535] 🏃‍♀️Players can use Hero NFT to battle against Thanos ⚔ Heroes can be Healed by staking their NFT 🛡

?? Fullstack Dynamic NFT Mini Game ?? ?? Using Diamond Standard Play On ?? ?? ⏩ http://diamond-dapp.vercel.app/ Project Description ?? Fullstack Dynam

Shiva Shanmuganathan 21 Dec 23, 2022
Rollback netcode for Mega Man Battle Network!

Tango Tango is rollback netplay for Mega Man Battle Network. Design Tango is composed of two parts: the launcher and the core. The launcher performs h

Tango 68 Dec 31, 2022
Pokémon: Duel Battle

Pokémon: Duel Battle Sebuah Web Apps yang dibuat sebagai syarat kelulusan Dicoding Submission Belajar Fundamental Front-End Web Development. Tech Proj

Ryan Aunur Rassyid 3 Sep 16, 2022
A recreation of a startpage posted on Reddit without the source, so I rewrote it in Next.js + Tailwind for the open source community.

Startpage "Figma Balls" Rewrite Why Did I Make This I saw a startpage posted on the subreddit r/startpages that I thought looked nice, but when I look

Thomas Leon Highbaugh 5 Mar 29, 2022
Omnivore - a complete, open source read-it-later solution for people who like text

Omnivore Omnivore is a complete, open source read-it-later solution for people who like text. We built Omnivore because we love reading and we want it

Omnivore 597 Jan 1, 2023
⚡️ A collection of open-source solution templates to integrate within Buildable Flows.

Buildable ⚡️ Buildable is an instant backend tool that makes a software developer’s day more delightful. We’re helping engineers breeze through featur

Buildable 161 Dec 15, 2022
GraphErr is an open-source error handling library for GraphQL implementations in Deno. It's a lightweight solution that provides developers with descriptive error messages, reducing ambiguity and improving debugging.

GraphErr Descriptive GraphQL error handling for Deno/Oak servers. Features Provides additional context to GraphQL's native error messaging for faster

OSLabs Beta 35 Nov 1, 2022
An open source, self-hosted, and entirely free solution to social media management.

An open source, self-hosted, and entirely free solution to social media management. Status ?? In Development ?? Shoutify is currently early in the dev

TechSquidTV 202 Dec 22, 2022
Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

Hasbik is a community based social token and the new paradigm in the crypto space. With the goal to build a community around a crypto token.

null 2 Jan 5, 2022
Klecks is the official open-source release of the community-funded online painting app Kleki.

Klecks (German for "splash of color", pronounced "clex") is the official open-source release of the community-funded online painting app Kleki. Klecks

I paint, code and mess around. 74 Dec 27, 2022
Updog is an open-source social media webapp intended to allow everyday people to share their thoughts in a welcoming community.

SE701-Updog Updog is an open-source social media webapp intended to allow everyday people to share their thoughts in a welcoming community. This proje

SE 701 Team 2 UoA 14 Apr 18, 2022
An Open Source Dev Community for Elite Developers by Ablestate Creatives Ltd.

Ablestate Dev Community Are you looking for a Developer Job in Companies in Europe, Canada and US. Get listed Fork Edit community.json Add your detail

Ablestate 6 Aug 20, 2022
Hydra bot is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node js

The most reliable WhatsApp tool for chatbots with advanced features. Hydra bot is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node js, . The most complete javascript library for Whatsapp, 100% Open Source.

Jónalan de Lima 47 Dec 25, 2022
The open source Community Operating System, built with developers in mind.

IMPORTANT: This project is still under active development. Be aware that future releases can lead to breaking changes. The open source Community OS, b

crowd.dev 383 Dec 29, 2022