spreadsheet icon indicating copy to clipboard operation
spreadsheet copied to clipboard

Support Table Styles

Open WoozyG opened this issue 8 years ago • 8 comments

Excel tables have their own styles, including 60 or so "built-in" styles defined in the Open Document specification.

I'm teaching POI about them for the 3.17 release, and adding some functionality and interfaces to bridge common information between conditional formatting and table styles, since both rely on the same underlying XML element type.

This means an opportunity to refactor my changes suggested in #461 to abstract out the CSS generation further and reuse it for tables as well.

Since a given cell can be formatted incrementally by multiple table style elements, such as both row and column styles together, the spec has a defined order of precedence for resolving conflicts. This works well with CSS too, as long as the order of style classes is similarly defined.

Once I have it working I'll submit a pull request that could cover both this issue and #461, but require the latest POI nightly or beta (if we have a 3.17 beta1 out by then).

WoozyG avatar May 12 '17 18:05 WoozyG

I have this fully working now in my own code, but it is piggy-backing on Conditional Formatting for the client CSS communication - I just carved out a different numerical namespace. Also requires changes introduced in POI trunk (will be in 3.17 beta 1) to expose the properties and teach POI about the Excel built-in table styles.

WoozyG avatar May 20 '17 04:05 WoozyG

Test file in Excel: excel

Test file in my app: vaadin

test file: tableStyleTest2.xlsx

WoozyG avatar May 20 '17 04:05 WoozyG

Note however that my temporary local solution is incomplete. To be correct, table styles need to be implemented in their own first-class widget connector property, as the order of format precedence is:

  1. Table style
  2. Cell explicit format
  3. Conditional formatting

Where the higher numbered elements override lower ones. To do this table styles need to be collected and converted to CSS on their own, so their rules can be output before cell and conditional rules. Those are already in the proper order in SheetWidget, just need to add tables to the mix.

WoozyG avatar May 22 '17 22:05 WoozyG

I'm happy to share my code when Vaadin Spreadsheet updates to a build of POI that includes the requisite changes.

The table style changes in POI also fix some issues around theme color tables, which will also simplify the Vaadin integration. Thanks for pointing to the POI bugs in the Vaadin source comments!

WoozyG avatar Jul 03 '17 22:07 WoozyG

Thanks again @WoozyG! This looks really promising. We can't update right away to 3.17 as it's not final yet, but I think we can create a branch to test the integration with latest beta and your changes. Could you attach a patch with your diff?

alvarezguille avatar Jul 04 '17 08:07 alvarezguille

I'll have to do it in stages. I have too many local changes to support all sorts of additional Excel chart properties and table functions.

I think first I'll submit a PR that just updates to remove the deprecated dependencies. In POI 3.15 we finally converted a ton of int constants to Enums. The old int methods go away in 3.17, but that breaks lots of code dependent on builds before 3.15.

Then I'll submit another PR that depends on that update so it can switch to POI 3.17 beta 1 and start incorporating the much improved table, theme, and conditional formatting support. This will involve a refactoring to some degree of the conditional formatting support to put table formatting ahead of cell format handling and conditional format handling, where it belongs, as it's own thing that users can override if needed.

There are also some changes for chart axes and other miscellaneous features, which I'll try to break out of my codebase into separate issues and PRs.

Will likely be spread over the next month or so, as I'm the only developer here on this project, and have part of my summer vacation starting next week :-)

WoozyG avatar Jul 05 '17 22:07 WoozyG

This is closely tied to the changes I'm submitting for #461, fixes for conditional formatting. They share some common code.

Should I try to tease out the common code and submit it with just one change first, and then the other separately, or make it one PR for both that issue and this one, as a comprehensive cell style/format update?

WoozyG avatar Jul 28 '17 20:07 WoozyG

Will see about doing common work in PR #701 and just table styling as a separate branch after.

WoozyG avatar Apr 08 '19 23:04 WoozyG