How can I create new CellStyles?

Feb 15, 2010 at 11:23 PM
Edited Feb 15, 2010 at 11:26 PM

I need to create unique number formats on the fly.  I would have prefered to use a template, but it is not feasible to maintain a template with all existing formats (not to mention future ones that could be created).  Is it possible with ExtremeML to create new NumberFormats and CellStyles that reference them?

I would want to do something similar to the solutions here or here.  I can't figure out how to use WorkbookStylesPartWrapper to do this.

Feb 16, 2010 at 8:24 AM
Edited Feb 16, 2010 at 8:26 AM

ExtremeML doesn’t currently offer any specific functionality to apply styling or formatting to a worksheet.

As you say, it's best to try to achieve this in the template if you can, but I understand that there may occasionally be scenarios where the template approach does not provide all the flexibility that your application needs. In such cases, the alternative is to work with the underlying SDK classes that ExtremeML wraps, using them to perform the low-level manipulation that you are seeking. Every wrapped SDK class exposes its properties via similarly named properties on the ExtremeML wrapper class.

If you choose this approach, I should warn you that it is very complex. If you are not already familiar with the SpreadsheetML formats, prepare yourself for a steep learning curve. Here is an article that explains the basic procedure for styling a cell. As you can see, this simple example requires many lines of code. It was this complexity (which is typical of all SDK operations, not just cell styling) that prompted me to develop ExtremeML in the first place.

If you intend delving into the inner workings of SpreadsheetML, it would also be worthwhile to read the OpenXML explained ebook, which includes a very good explanation of how all the styling elements relate to each other.

In the future ExtremeML will be extended to include explicit support for styling and formatting, but this requires a considerable development exercise, so I couldn’t promise when it might be complete.