Open peoplenarthax opened 6 years ago
I think I'll err to the answer I've previously given, that features like these would be lovely. I think they should come in some kind of plugin structure, so consumers can still get a minimal bundle if they don't need anything else.
The initial vision (which can definitely be challenges) was to create the smallest possible library to produce a valid xlsx file in the browser.
I totally agree with the vision and actually I quite like the job that has been done here (it's impossible to get a non overkilling xlsx exporter library). Is there a roadmap to achieve a plugin hierarchy? Some proposal? I would love to contribute more to this.
Not at all. It's not something I have personally pursued, so it would have to be a community effort 🙂
I see and understand your position regarding the smallest possible library. I think it might be shortsighted since without styling, formulae, multiple sheets or charts there is no reason to use this over a plain csv file.
a simple solution: make a standard add-on syntax like this (add col definition to sheet object) cols:[{width:150},{width:75}]
and an article about how you would add a handler to the code. it is OK to make us work for it, but as it stands I don't see any reason to use zipcelx.
@jphardman Reason is simple: MS Excel sucks at importing CSV. That's why we adopt zipcelx in my previous company.
@egeriis I think I'll err to the answer I've previously given, that features like these would be lovely. I think they should come in some kind of plugin structure [...]
I totally agree with it. The question is: how to make zipcelx modular. Because right now, we just return strings.
Maybe instead of strings, we should use DOM Methods. This way we can add hooks for plugins.
I.E:
export generatorNumberCell (index, value, rowIndex) => (`<c r="${generatorCellNumber(index, rowIndex)}"><v>${value}</v></c>`);
const generatorNumberCell = (index, value, rowIndex) => (`<c r="${generatorCellNumber(index, rowIndex)}"><v>${value}</v></c>`);
Become
const generatorNumberCell = (index, value, rowIndex) => {
const cell = document.createElement(c);
c.addAttribute('r', generatorNumberCell(index, rowIndex));
const cellValue = document.createElement(v);
v.innerText = value;
cell.appendChild(cellValue);
return cell;
}
And then we can call cell hooks and pass to them the new Element. I.E:
const cell = generatorNumberCell(a, b, c);
plugins.cell.forEach(plugin => plugin(cell));
âš Please note that this is not a pure and functionnal way of doing things... so this could easily leads to unexpected problems.
What do you think ?
I gave it a thought for quite some time and never came with a proper solution for a plugin system were you could hook your functions (like adding color to cells, formulas etc etc). Your idea could be a first iteration at least @doliG
Hello!
I was taking a look at the OpenXML format for styling at cell level or even at Table level. Nothing too powerful but at least allow a minimal amount of formatting (font styling / bgColor). I believe that this can increase the bundle size but not in a big scale. My question is more, What is the bundle size / minimum feature proportion to consider such a change?
Maybe we can define the feature: Add solid background color. Add font styling such as italic/bold/under Add font alignment center/right(default)/left
I am doing a bit on work about this but I want to know if I should consider PR 😄