This project has moved and is read-only. For the latest updates, please go here.

Can I create styles and use them in different workbooks (or packages)?

Mar 24, 2011 at 12:30 PM


The EPPlus library you are creating is very useful! Thanks for the effort!

I was using a similar library called XmlExcel written by a guy named Yogesh Jagota ( and, although I found it simple to use, I ended up ditching it because its bugs and quirks made it quite frustrating and the author had stopped developing it any further.

I have been able to migrate most of my code to the EPPlus library and I love how everything just works as it should. However, there is a thing I haven't been able to replicate which is the creation of workbook-independent (or package-independent) styles that I can then use in different workbooks (or packages). In the XmlExcel library I could write something along the lines of XmlStyle MyStyle = new XmlStyle() and then set all the MyStyle style properties to whatever I wanted (similar to what you can do in the EPPlus library with named styles). Since MyStyle was defined outside of the scope of a workbook, I could then use it in any of the workbooks that I created.

Right now I need to re-define all the named styles in every workbook (or a package) and I wish I could just share the same styles through my code. I have noticed that the OfficeOpenXml.ExcelStyles.CreateNamedStyle(string) can also be called with an extra parameter OfficeOpenXml.ExcelStyles.CreateNamedStyle(string, OfficeOpenXml.Style.ExcelStyle) that I imagine is some sort of template. How can I create this template? Can it be shared accross workbooks (or packages)? Can I apply the template directly to a cell (or cells) without using named styles?



Mar 25, 2011 at 3:49 PM


No, there is not simple way to share styles between workbooks at the moment, but it shouldn't be to hard to add (it's done inside the worksheet.Copy method).

You can copy styles inside a package by setting the StyleID for a range.

If it turns out to be simple, I'll try to add some style copy functionallity to the next version.


Mar 28, 2011 at 11:57 AM

Thanks for the answer! I will check future versions to see if the functionality is implemented. Congratulations on the good work!