This project has moved. For the latest updates, please go here.

Add Styles to workbook

Oct 18, 2012 at 2:11 PM

Hi. I want to add some specific styles to a workbook. These styles should be available for the users that use the workbook, after our code generated it. I couldn't find the possibility within the ClosedXml library. I found the styles.xml within the xlsx container. So it should be possible to add it manually with some code... I do not want to set the style, i just want to add it, that it is available in the styles ribbon.

Did i miss some functionality or is it not supported?

I found a related article: http://closedxml.codeplex.com/discussions/264553

But it is not exactly what i mean...

Coordinator
Oct 18, 2012 at 3:14 PM

Sorry, it's not supported.

Jul 31, 2014 at 4:48 PM
How about changing the style of the workbook?
var workbook = new XLWorkbook();
workbook.Style.Font.SetFontName("Open Sans");
that throws a NullReferenceException
   at ClosedXML.Excel.XLFont.SetFontName(String value) in c:\ClosedXml\ClosedXML\ClosedXML\ClosedXML\Excel\Style\XLFont.cs:line 320
   at ClosedXML_Examples.HelloWorld.Create(String filePath) in c:\ClosedXml\ClosedXML\ClosedXML\ClosedXML_Examples\HelloWorld.cs:line 13
   at ClosedXML_Examples.CreateFiles.CreateAllFiles() in c:\ClosedXml\ClosedXML\ClosedXML\ClosedXML_Examples\Creating\CreateFiles.cs:line 17
   at ClosedXML_Examples.Program.Main(String[] args) in c:\ClosedXml\ClosedXML\ClosedXML\ClosedXML_Examples\Program.cs:line 8
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()