Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cell Styling #50

Open
peoplenarthax opened this issue Oct 10, 2018 · 6 comments
Open

Cell Styling #50

peoplenarthax opened this issue Oct 10, 2018 · 6 comments

Comments

@peoplenarthax
Copy link
Contributor

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 😄

@peoplenarthax peoplenarthax changed the title Stylings Cell Styling Oct 10, 2018
@egeriis
Copy link
Owner

egeriis commented Oct 10, 2018

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.

@peoplenarthax
Copy link
Contributor Author

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.

@egeriis
Copy link
Owner

egeriis commented Oct 10, 2018

Not at all. It's not something I have personally pursued, so it would have to be a community effort 🙂

@jphardman
Copy link

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.

@doliG
Copy link

doliG commented Sep 21, 2019

@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 ?

@peoplenarthax
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants