Examples and documentation improvements #64
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#64
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I am looking for an example on writing a JSON into xlxs file.
The read works great but I unable to find a working example. Can someone help me with a link or simply point me in the right direction.
@nukulb the write process takes a JSON object as described in the Cell Object Description section, which isn't particularly convenient ATM. I am working on a way to take a CSV or row object array and convert to the internal format.
As a simple example using the intermediate format, suppose your data was in a 2d grid:
http://i.imgur.com/wfijIov.png
Suppose you wanted to write that to a sheet called "SheetJS". Then the code would be:
In the future, there will be utility functions to handle most of the logistics for you.
Preemptively closed this -- will deem complete once the documentation is up to snuff
@SheetJSDev thanks a lot, I will try it out today but looks straightforward.
@nukulb how is it going?
I am starting this work tomorrow, I got side tracked with other stuff.
Thanks for checking in.
On Wed, May 28, 2014 at 6:24 PM, SheetJSDev notifications@github.comwrote:
Nukul Bhasin
that seems to be failing on the last line when I got to write the file.
Output XLSX
Do I need a different version for the 'writeFile' method?
seems like npm has a very old version of this.
I ran npm pack myself to get 0.7.3 version and this example works.
@SheetJSDev any chance you publish the latest to npm?
@nukulb https://www.npmjs.org/package/xlsx shows that the latest version is 0.7.3 and has been there for the last 4 days. What version of node/npm are you using? Also, can you show the line for xlsx in your package.json?
you are correct, npm has the right version problem seems to be on my end. I will figure it out on my end.
Your code seems to be work fine. I will start doing some more complicated stuff tomorrow and I might ask more questions here. I really appreciate your help. Thanks.
The README has a few browser and nodejs examples and the test suite also includes ad-hoc and round trip tests. Closing for now. If you encounter an issue with the examples please raise a new issue.
So far I have only used to write to a new file. And it works great for this use case. Thanks for all the support.
The next thing I am looking at is opening an existing file and then write to that file. Is there an example of this available?
Since they use the same internal format, you can also use https://github.com/SheetJS/js-xls :
The test suite has a round trip section just for this: https://github.com/SheetJS/js-xlsx/blob/master/test.js#L630
Reopening since there is no complete example of editing an existing file in the documentation.
Hello,
Simplifying the read/write interfaces is something I'd like to see as well. I feel the current forms of traversal are too cumbersome.
Any thoughts on what cleaner interfaces should look like?
Are there "common structures" to Excel files the library should support? for example, simple tables?
@eladxxx I agree that there should be a layer between the raw representation and applications. The interface is a tricky problem for a few reasons:
you've read a file with three cells. A1=1, A2=2, A3=A1+A2. If you make a change to A1 (let's say A1=2 now) do you update the value of A3? You could also just mark the value as dirty.
you delete a cell. How do you update the other cells to be consistent? It's possible (via cross-sheet references) that you would have to look at every sheet. Also, do you shift left or up?
There should be a function interface so that we could easily change the model later (that probably should have been built at the beginning :/ c'est la vie), including:
... and a separate function for each fundamental operation.
I'm inclined to keep this in a separate library and make the parsers expect a Workbook object -- there would be a dumb workbook implementation in this and in js-xls and they would use something more intelligent if you included the other script in the browser.
NB: To support opening and editing files, we would probably need a real engine that can parse excel formulae (and, if we are ambitious, evaluate). Since that formula engine is also needed for shared formulae (see https://github.com/SheetJS/js-xlsx/pull/67) that might be done sooner rather than later.
You raise a lot of good points. However, what I meant by simple - and it could very well be that I'm looking at this too subjectively - is that we agree on some "common" input format(s) and work with that.
For example, I deal with a lot of files that are simple tables. Some of them have the first row as headers, some don't. Think CSV data imported into Excel. It would be nice if the library had a built-in function to read this type of data so that I could do:
The idea of course isn't to provide
read_rows
as suggested above but to give something super simple to use in just a couple of lines of code to achieve common goals.Of course if we can't agree on common goals and/or "common" means formulae-heavy documents and such, then it might be that more thought should be given to how this simplification happens.
That said, the interface functions you suggest seem useful, though I'm not sure they help in iterating over a document in order to parse it for some internal representation.
@eladxxx As part of this issue from js-xls the JSON output function was overhauled. If you are specifically interested in the data, this should work:
If need be,
sheet_to_json
can be modified to optionally return the full object as well as row-level metadata.Is there any documentation for
sheet_to_json
? Specifically, a way to tell it "there are no headers in the data"? passing no options, or explicitly passing{ header: 0 }
(or -1) doesn't do the trick...@elad this is how i described the header option in the other thread:
1
generates an array of arrays (data starts in first row)'A'
generates a structure using the column headers as keys (data starts in first row)(default behavior remains: use the first row as headers)
this clearly needs to be documented properly
Is there an API to initiate a workbook now?
https://github.com/SheetJS/js-xlsx/issues/365
It would be great if the documentation listed accepted "type" values for the read() function (and what those options mean). For example: buffer, base64, file, binary, etc.
Are pull requests being looked at? If so, I'd be up for helping out on this.
We're slowly improving the documentation. The underlying structure is stabilizing, and for most supported features all of the parsers should generate the same fields consistent with the README.
At the moment we're trying to go feature by feature and hammer out documentation while we ensure the main supported parsers (XLS/XLSX/XLSB/SpreadsheetML) produce similar parsed objects. If there is anything unclear in the README please let us know where we can improve.
@blakek if you are interested in contributing documentation, we'd gladly accept a PR! Documentation is the one area that doesn't involve hours of testing :D If you have any demos or projects, please add a link to the wiki page so others can find it!
We set up a gitbook integration: https://sheetjs.gitbooks.io/docs/