title: Regular Expression RegEx to validate Custom Excel formats
body: <p>I am creating Excel spreadsheets programmaticly (in C#/.Net using <a href="http://epplus.codeplex.com" rel="nofollow">the fabulous EPPlus library</a>) and am passing in an array of cell ranges (string-based) and the custom format string to apply to these ranges.</p>
  
  <pre><code>// Struct:
  public struct ExcelColumnFormat
  {
      public string CellRangeDefinition;
      public string ExcelFormatString;
  }
  </code></pre>
  
  <p>-</p>
  
  <pre><code>// Usage
  ExcelHelper.ExcelColumnFormat[] formats = new ExcelHelper.ExcelColumnFormat[1];
  formats[0].ExcelFormatString = "$#,##0.00";
  formats[0].CellRangeDefinition = "I:I";
  </code></pre>
  
  <p>-</p>
  
  <pre><code>// Consumption / application of those formats
  foreach (ExcelColumnFormat format in formats)
  {
      // Make sure that there are non-zero or null strings passed in
      if (!String.IsNullOrEmpty(format.ExcelFormatString) &amp;&amp; !String.IsNullOrEmpty(format.CellRangeDefinition))
          ws.Cells[format.CellRangeDefinition].Style.Numberformat.Format = format.ExcelFormatString;
  }
  </code></pre>
  
  <p>I am already checking the strings for IsNullOrEmpty, but I wanted to put another level of validation to test if the custom format strings are, in fact, valid Excel formats.  Here is a <a href="http://office.microsoft.com/client/helppreview14.aspx?AssetId=HP010342372&amp;lcid=1033&amp;NS=EXCEL&amp;Version=14&amp;tl=2&amp;CTT=5&amp;origin=HA010352461" rel="nofollow">link to the Office help file that describes the rules around Excel Formats</a>.</p>
  
  <p><strong>The question is:</strong> given the many permutations available in custom Excel formats, is this a worthwhile endeavor and how might the RegEx look?</p>
  
  <p>Thanks in advance!</p>