protobi / js-xlsx

XLSX / XLSM / XLSB (Excel 2007+ Spreadsheet) / ODS parser and writer
http://oss.sheetjs.com/js-xlsx
Other
814 stars 416 forks source link

status of this project? #125

Open westwick opened 5 years ago

westwick commented 5 years ago

Hello, I found this repo like most people after realizing the original forked project doesn't provide style support, and am trying to incorporate it into an Angular project. I have it working but it feels very "hacky" and just wondering if this is normal, or am I doing something wrong, and what the status of this fork is?

For example, to even get it to work I had to modify cpexcel.js and remove the require for cptable (replaced with var cpt = cptable;). Should this change be committed and released to npm?

Also, some of the functionality from original xlsx-js appeared to not be working in this fork, e.g. utils.book_new() was not working, utils.book_append_sheet(), utils.json_to_sheet(), writeFile(), etc. -- so what I ended up having to do was use both forks of this project, and export from xlsx then import into xlsx-style, like so:

import * as XLSX from 'xlsx';
import * as sheets from 'xlsx-style';

const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, someSheet, 'sheetname');
const out = XLSX.write(wb, { type: 'base64'});

// take the output from xlsx lib and pass it into xlsx-style lib
const styledwb = sheets.read(out);
// we can now apply styles
// however writeFile wasn't working so had to add implementation to convert and trigger download with file-saver
const newOut = sheets.write(styledwb, wopts); // ouput type=binary
const test = new Blob([this.s2ab(newOut)], {type: ''});
saveAs(test, 'test.xlsx');

So this all works, but I guess my big question is, am I doing something wrong? Are those functions expected to work in this fork, or is the above code basically necessary at this point in time? Thanks for any insight!

pietersv commented 5 years ago

@westwick Great question, if you can contact me directly it'd be great to have a thought partner to think through this. I'd like to develop this further but the conundrum is while there seems to be a market need to develop this branch of js-xlsx it may consist of exactly zero customers as there is a separate commercial branch for anyone with a budget.

westwick commented 5 years ago

sure will reach out

jlbeard84 commented 5 years ago

+1 for being interested in further developments 👍

donhmorris commented 5 years ago

I would be interested in seeing this go further since getting the pro version is a clunky process.

I too was puzzled in how to use this package. I looks to me you use the original xlsx package to setup your sheets and then you render (write) with this package. That is what worked for me. I did find a bug in processing fills with a background color for cells. I'm modifying my local and may try to get my fix into the repo.

jlbeard84 commented 5 years ago

@donhmorris I ended up forking another library and adding fills for background colors. It ended up being a little closer to my requirements.

https://github.com/jlbeard84/zipcelx if you're interested at all.

donhmorris commented 5 years ago

@jlbeard84 Thanks for sharing.

My client wants to use excel as a report rendering engine with colors, headlines, groups, etc. In his domain they use excel to pass around information quite a bit.

If I get stuck I may setup a windows server in amazon light sail and use .net. I’ve used .net for creating custom excel workbooks before. The libraries and tools are really good for this in .net.

pietersv commented 5 years ago

@donhmorris This library supports background colors, etc, lots of examples in example_style.js. Try installing it from github directly (git install github:protobi/js-xlsx) rather than npm.

For what you're doing setting up a separate server shd not be necessary.

If all you're doing is creating Excel XLSX and you don't need to read XLSX, XLS or write XLSB files, then there a lots of node libraries to suport that. One very lightweight one is msexcelbuilder. https://github.com/protobi/msexcel-builder.

pietersv commented 5 years ago

this is #90

donhmorris commented 5 years ago

I tried with rgb values and it paints in black every time.

I’m pretty sure I found a bug in the code. I’ll try github and I will also try using an indexed color with the theme.