views:

143

answers:

1

I'm currently working with v2.0 of the SDK to generate an Excel workbook and it was all going well until I came to apply the cell formatting.

I've created a few CellFormats and successfully applied them but there are a few more permutations that I need to configure:

  • 4 fonts (normal, bold, italic and bold+italic)
  • 5 number formats
  • 3 alignments (left, right and centre)
  • 2 border (none and top+bottom)

This equates to 120 styles - do I really need to configure a CellFormat for each one? Surley that's the road to madness ;-)

If that's the way it has to be then I'm happy with the generation of the CellFormats collection but I'm concerned about referencing the formats when applying them - it all sounds too flaky to me.

I've posted this in OpenXMLDeveloper but it's still pretty quiet in there so I'm hoping the SO can come to my rescue.

A: 

Well the answer to this question appears to be Yes!

I identified the possible permutations and created a method that accepted parameters such as FontId and BorderId.

I then just called the method about 20 times to create a collection of Styles that I needed.

I still think this is a bit on the clunky side ;-)

DilbertDave