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

applyNumberFormat flag in cellStyle XF field set to 0 by ClosedXML. Why?

Sep 18, 2014 at 6:59 PM
As I understand it, the applyNumberFormat flag in a cellStyle XF record indicates whether or not a number format should be applied. When configuring a number format in ClosedXML (example link included below), the applyNumberFormat flag is set to 0. Excel doesn't have a problem with it, and will use the number format anyways. But I'm curious to know why ClosedXML does this. I support an old Windows application that reads this flag to determine if the number format should be used, and the number formatting won't work with any files created with ClosedXML.
Sep 19, 2014 at 6:44 PM
I had to look around and think about this one for a while because, as always, my default is that there's got to be a reason for the way things are. In this case there isn't.

Pick up the latest source code. I made ApplyNumberFormat to always be true (if you don't apply a format it will still have the number format of zero, which is perfectly valid). I'm going with this approach because keeping track of when you set the format explicitly is rather cumbersome. It's also unnecessary considering that even Excel makes ApplyNumberFormat true when it's not needed.

Let me know if you have other problems.
Sep 19, 2014 at 10:42 PM
Wow, I didn't expect such a quick and detailed response. Thanks for the explanation and code change. You've got a nice project here!