Giter VIP home page Giter VIP logo

Comments (7)

scpike avatar scpike commented on July 17, 2024

I'm interested in this feature. I started working on it in my fork (progress so far), but I have a couple of questions.

  1. Generally speaking, I added ConditionalFormatting and ConditionalFormattingRule classes, and a add_conditional_formatting function to Worksheet. Is that in line with what you'd do?

  2. I tried to add validators to check types of things against what's in the spec. Have you just been going off of MSDN? http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.conditionalformattingrule.aspx

  3. I got the conditionalFormatting blocks to generate correctly, but I can't get the styling piece added to the stylesheet. I'm not entirely sure what a dxfId is - it seems like it's the index into the <dxfs> block in the stylesheet. Is there any way for me to create styles that get put inside that block with the current style code? You have a @dxfs variable but 1) doesn't seem like it ever gets set and 2) The to_xml code wouldn't seem to generate sub-blocks of <dxf></dxf> from it.

As an example, here's what Excel on Mac generates (closing </cellStyles> tag just to show position)

</cellStyles><dxfs count="3"><dxf><font><color rgb="FF9C0006"/></font>
    <fill><patternFill><bgColor rgb="FFFFFFFF"/></patternFill></fill>
</dxf></dxfs>

from axlsx.

randym avatar randym commented on July 17, 2024

@scpike woot!
That is a big chunk of love!

RE: 1) Absolutely perfect.

  1. I always use the Office Open XML spec
    http://dl.dropbox.com/u/52469356/ECMA-376.1.zip

  2. You are quite correct that we have not implemented xdf yet. That is the missing piece!
    18.8.14 dxf (Formatting) in the spec.

It is basically a container node for
alignment (Alignment) (§18.8.1)
border (Border) (§18.8.4)
fill (Fill)(§18.8.20)
font (Font)(§18.8.22)
numFmt (Number Format)(§18.8.30)
protection (Protection Properties)(§18.8.33)

Models for all of those objects are already in the stylesheet directory, I just never got around to making a dxf class :(

The last step would be adding adding an option for add_style to mark the style as differential and return the dxfs index so when you create your conditional_formatting_rule, you have an dxfId.

In the mean time, please send in a pull request for your stuff!
I'll merge it in and add you to the contributors list so you can code directly against master.

from axlsx.

scpike avatar scpike commented on July 17, 2024

I did some more work on this today, and Dxf elements now exist. I think all the commits got automatically added to the pull request I sent earlier.

I did a bunch of messing around with Styles#add_style so that styles for Xf elements continue to get put inside @numFmts, @fills, @fonts, etc. while Dxf styles don't (they only get put inline in the <dxf> chunks. It still passes all your tests and I added some for dxfs, but you should take a look at the changes there before you merge it in in case we want to do some re-factoring.

With the most recent commits I'm able to create .xlsx files with working conditional formatting (see examples/example_conditional_formatting.rb). We're still missing support for dataBar, colorScale, and iconSet child elements of ConditionalFormattingRule, which aren't that important to me.

from axlsx.

randym avatar randym commented on July 17, 2024

@scpike This is really great work mate. You now have full access to the repo so when you run into something you want, please don't hesitate to add it in. I am really impressed with the quality of your work. I've set you up with direct access to the repo. If you ever have any questions you can usually find me lurking in #axlsx (the ci environment for this gem reports there) or #travisci on freenode.

I just plugged in colorScale and will knock off dataBar and iconSet today as well so we can call it done (until someone reports a bug of course!)

That Style#add_style method does indeed need a bit of love - but I am so impressed with this I think I'll release it next week with a blog post! Let me know your twitter handle if you have one.

from axlsx.

randym avatar randym commented on July 17, 2024

It is all implemented - but we need some testing help!

After spending a few hours to build in icon set, data bar and color scale - only to find out that my crappy 2007 Mac version tells me very politely that it does not support those conditional formats. Any out there have a windows version handy to do some testing? No validation errors or fix errors so the data should be clean - just cant verify if it actually works...

from axlsx.

scpike avatar scpike commented on July 17, 2024

@randym Thanks for the compliment, you really know who to make a guy want to contribute!

I have Excel for Mac 2011, which supports icon set, data bar, and color scale. They worked with no errors, but the Icon set showed all green lights. I modified IconSet#initial_value_objects to have three based on percentages, so our default now matches the example in 18.3.1.49, and got a much nicer looking thing.

Color scale
Data bar
Icon set

from axlsx.

randym avatar randym commented on July 17, 2024

That is AWESOME!

from axlsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.