Removing default header/footer style markup

Jan 16, 2012 at 1:26 AM

Hello Manuel,

First of all, thank you so much for your work on ClosedXML.  I have just one improvement to suggest.

As you know, headers and footers in Excel are limited to 255 characters.  Unfortunately, ClosedXML introduces default style markup which effectively reduces this to 162 characters.  Consider the following VB.Net code:

ws.PageSetup.Footer.Left.AddText("text1")
ws.PageSetup.Footer.Center.AddText("text2")
ws.PageSetup.Footer.Right.AddText("text3")

which produces the following footer string:

&L&"Calibri,Regular"&11&K000000text1&C&"Calibri,Regular"&11&K000000text2&R&"Calibri,Regular"&11&K000000text3

As you can see, 87 characters are used to define the default style three times, when the following would be much shorter and just as effective:

&Ltext1&Ctext2&Rtext3

The default style appears even when a custom style is defined, as shown in the following code:

ws.PageSetup.Header.Right.AddText("&22&""Times New Roman,bold""DRAFT")

which produces this:

&R&"Calibri,Regular"&11&K000000&22&"Times New Roman,bold"DRAFT

instead of this:

&R&22&"Times New Roman,bold"DRAFT

I often produce spreadsheets with ~200 characters in the footers, but I can't create them with ClosedXML because of this issue.  Could you either remove the default style markup or provide an option to define the headers/footers without this markup?

Thanks for your help,
Matt

Coordinator
Jan 16, 2012 at 1:31 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 16, 2012 at 3:14 AM

I couldn't remove "-,Regular" in a safe way so everything is out except this tag.

Thanks for feedback.