Giter Club home page Giter Club logo

j's Introduction

J

NOTE: this library / tool is a relic from a time when the SheetJS Spreadsheet Parsing and Writing libraries were separate entities. They have been unified in the js-xlsx project, xlsx on NPM. New projects should be using that library directly.

Simple data wrapper that attempts to wrap SheetJS libraries to provide a uniform way to access data from Excel and other spreadsheet files:

Excel files are parsed based on the content (not by extension). For example, CSV files can be renamed to .XLS and excel will do the right thing.

Supported Formats:

Format Read Write
Excel Worksheet/Workbook Formats :-----: :-----:
Excel 2007+ XML Formats (XLSX/XLSM)
Excel 2007+ Binary Format (XLSB BIFF12)
Excel 2003-2004 XML Format (XML "SpreadsheetML")
Excel 97-2004 (XLS BIFF8)
Excel 5.0/95 (XLS BIFF5)
Excel 4.0 (XLS/XLW BIFF4)
Excel 3.0 (XLS BIFF3)
Excel 2.0/2.1 (XLS BIFF2)
Excel Supported Text Formats :-----: :-----:
Delimiter-Separated Values (CSV/TXT)
Data Interchange Format (DIF)
Symbolic Link (SYLK/SLK)
Lotus Formatted Text (PRN)
UTF-16 Unicode Text (TXT)
Other Workbook/Worksheet Formats :-----: :-----:
OpenDocument Spreadsheet (ODS)
Flat XML ODF Spreadsheet (FODS)
Uniform Office Format Spreadsheet (标文通 UOS1/UOS2)
dBASE II/III/IV / Visual FoxPro (DBF)
Lotus 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)
Quattro Pro Spreadsheet (WQ1/WQ2/WB1/WB2/WB3/QPW)
Other Common Spreadsheet Output Formats :-----: :-----:
HTML Tables
Rich Text Format tables (RTF)
Ethercalc Record Format (ETH)
Markdown Tables
XML Data (XML)

circo graph of format support

Installation

$ npm install -g j

Node Library

var J = require('j');

J.readFile(filename) opens file specified by filename and returns an array whose first object is the parsing object (XLS or XLSX) and whose second object is the parsed file.

J.utils has various helpers that expect an array like those from readFile:

Format utility function
Excel 2007+ XML Formats (XLSX/XLSM) to_xlsx/to_xlsm
Excel 2007+ Binary Format (XLSB BIFF12) to_xlsb
Excel 2.0/2.1 (XLS BIFF2) to_biff2
Delimiter-Separated Values (CSV/TSV/DSV) to_csv/to_dsv
Data Interchange Format (DIF) to_dif
Symbolic Link (SYLK/SLK) to_sylk
OpenDocument Spreadsheet (ODS) to_ods
Flat XML ODF Spreadsheet (FODS) to_fods
HTML Tables to_html
Markdown Tables to_md
XML Data (XML) to_xml
Ethercalc Record Format (ETH) to_socialcalc
JSON Row Objects to_json
List of Formulae to_formulae

CLI Tool

The node module ships with a binary j which has a help message:

$ j --help

  Usage: j.njs [options] <file> [sheetname]

  Options:

    -h, --help               output usage information
    -V, --version            output the version number
    -f, --file <file>        use specified workbook (- for stdin)
    -s, --sheet <sheet>      print specified sheet (default first sheet)
    -N, --sheet-index <idx>  use specified sheet index (0-based)
    -p, --password <pw>      if file is encrypted, try with specified pw
    -l, --list-sheets        list sheet names and exit
    -o, --output <file>      output to specified file
    -B, --xlsb               emit XLSB to <sheetname> or <file>.xlsb
    -M, --xlsm               emit XLSM to <sheetname> or <file>.xlsm
    -X, --xlsx               emit XLSX to <sheetname> or <file>.xlsx
    -Y, --ods                emit ODS  to <sheetname> or <file>.ods
    -8, --xls                emit XLS  to <sheetname> or <file>.xls (BIFF8)
    -5, --biff5              emit XLS  to <sheetname> or <file>.xls (BIFF5)
    -2, --biff2              emit XLS  to <sheetname> or <file>.xls (BIFF2)
    -6, --xlml               emit SSML to <sheetname> or <file>.xls (2003 XML)
    -T, --fods               emit FODS to <sheetname> or <file>.fods (Flat ODS)
    -S, --formulae           emit list of values and formulae
    -j, --json               emit formatted JSON (all fields text)
    -J, --raw-js             emit raw JS object (raw numbers)
    -A, --arrays             emit rows as JS objects (raw numbers)
    -H, --html               emit HTML to <sheetname> or <file>.html
    -D, --dif                emit DIF  to <sheetname> or <file>.dif (Lotus DIF)
    -U, --dbf                emit DBF  to <sheetname> or <file>.dbf (MSVFP DBF)
    -K, --sylk               emit SYLK to <sheetname> or <file>.slk (Excel SYLK)
    -P, --prn                emit PRN  to <sheetname> or <file>.prn (Lotus PRN)
    -E, --eth                emit ETH  to <sheetname> or <file>.eth (Ethercalc)
    -t, --txt                emit TXT  to <sheetname> or <file>.txt (UTF-8 TSV)
    -r, --rtf                emit RTF  to <sheetname> or <file>.txt (Table RTF)
    -x, --xml                emit XML
    -m, --markdown           emit markdown table
    -F, --field-sep <sep>    CSV field separator
    -R, --row-sep <sep>      CSV row separator
    -n, --sheet-rows <num>   Number of rows to process (0=all rows)
    --sst                    generate shared string table for XLS* formats
    --compress               use compression when writing XLSX/M/B and ODS
    --read                   read but do not generate output
    --all                    parse everything; write as much as possible
    --dev                    development mode
    -q, --quiet              quiet mode

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.

Build Status

Coverage Status

NPM Downloads

Dependencies Status

ghit.me

Analytics

Using J for diffing spreadsheet files

Using git textconv, you can use J to generate more meaningful diffs!

One-time configuration (misc/gitdiff.sh):

#!/bin/bash

# Define a sheetjs diff type that uses j
git config --global diff.sheetjs.textconv "j"

# Configure a user .gitattributes file that maps the xls{,x,m} files
touch ~/.gitattributes
cat <<EOF >>~/.gitattributes
*.xls diff=sheetjs
*.xlsb diff=sheetjs
*.xlsm diff=sheetjs
*.xlsx diff=sheetjs
*.XLS diff=sheetjs
*.XLSB diff=sheetjs
*.XLSM diff=sheetjs
*.XLSX diff=sheetjs
EOF

# Set the .gitattributes to be used for all repos on the system:
git config --global core.attributesfile '~/.gitattributes'

If you just want to compare formulae (for example, in a sheet using NOW):

git config --global diff.sheetjs.textconv "j -S"

NOTE: There are some known issues regarding global modules in Windows. The best bet is to npm install j in your git directory before diffing.

j's People

Contributors

sheetjsdev 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

j's Issues

Segmentation fault when accessing a xlsb file

EDIT: this is a bug in node v0.10.31 (nodejs/node-v0.x-archive#8208). If you find repeated segmentation faults, try rolling back to node 0.10.30. On linux and OSX, n on npm (https://www.npmjs.org/package/n) removes most of the hassle of switching between node versions.

Hi,

I'm trying to extract a sheet from a xlsb file. However when I open the file, I get the message "Segmentation Fault".
Same error occurred when I ran "j -l file.xlsb"
I'm just wondering how do I resolve that.

standalone

Can I build a standalone command that doesn't require nodejs?

Clipboard support

Is there a way to take an excel file and copy to clipboard so that I can paste into google spreadsheet?

How to default all sheets

Hi, I'm trying to convert my xlsx to csv from command line. But when I do, it only grabs first sheet. I know I can set the sheet with -s operator, but I'd like to automate this as much as possible. How do I grab all sheets? Not knowing what they may be called, since they are not labeled 0, 1, 2, etc... and sheet operator only works by naming sheet, i.e. j file.xlsx -s "My Sheet"

Make __rowNum__ non-enumerable

Currently all rows returned by to_json have a __rowNum__ property on their prototype. However, this property is enumerable, which causes it fail chai's deepEqual test.

If the property was non-enumerable this would make life much easier.

This affects both js-xls and js-xlsx. It does also affect CSV parsing with j, but did not find any __rowNum__ references in js-harb so I expect this is to due with the shared json output.

Thanks.

Merging various projects (js-xls, js-xlsx, js-harb)

This discussion has come up various times, and every time I've been hesitant due to size constraints, but it's becoming clear that the separate projects are slowing development.

Even worse, much of the code is duplicated in both projects, so merging would slim down the total size in a clean way (as opposed to various ad-hoc solutions). FYI The proverbial straw that broke the camel's back involved style parsing in XLS, which requires a stripped down version of the XLSX style parsing code (brilliant design on Microsoft's part to embed a ZIP file within the container).

Since github has no way to indicate that we are merging the projects, we will have to do it manually.

Questions:

  1. The XLS, XLSX and HARB objects have the same interface, so we can fold all of the logic into one of the projects or create a new project. Which makes more sense?

  2. Should the build process create separate scripts for the individual formats (an xls.js for the XLS format, xlsx.js etc)?

  3. What should happen to the node modules and the other repos?

Pulling @elad @nathanathan @notatestuser

Define Decimal Precision

I am importing an excel file. By default Excel Internally handles decimals to the 15th place or something, but display these numbers as to a precision of 2 places behind the floating point.

When importing with J and xlsx.js it takes "what the human eye sees" out of the cells, but not the underlying values, internally held by excel.

Is there a method to define decimal precision when importing / exporting excel files?

If not, consider this is a feature request.

ODS support

OpenDocument Spreadsheet (.ods) format is supported in Excel 2013

to_json omits empty cells

Hi,

It seems that to_json uses undefined for empty cells. This makes it rather difficult to validate sheets with optional columns, or to ensure that there are no extra columns or extraneous data in unnamed columns.

In the same way, get_cols also omits any column with an empty header cell.

Could this be changed to use empty string or null?

Thanks.

Reading Wrong date from DBF

Hi,

When I am reading date from dbf file suppose 18/01/1974 which is in date format, J parser returning date as 17/01/1974. I am unable to understand why this is happening. Please help

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.