Excel number format strings are cryptic; but there are smallish number of common ones that are accessible via the toolbar (e.g., Accounting or Percent). It would be really handy to have a builder class for these things in GemBox.Spreadsheet. I've started cobbling together a class of my own, with methods such as the ones below. I feel like I've got to be reinventing some wheels here; but I haven't turned up anything on the Web....
// e.g., 12,345.67, (12,345.67), - public static string Accounting(int numDecs) { return String.Format("_(* #,##0{0}_);_(* \\(#,##0{0}\\);_(* \"-\"??_);_(@_)", DecimalPlaceholder(numDecs)); } // e.g., 12.3%, -12.3%, 0.0% public static string Percent(int numDecs) { return String.Format("0{0}%", DecimalPlaceholder(numDecs)); } // Generates "", ".0", ".00", etc. depending on numDigits. private static string DecimalPlaceholder(int numDigits) { var fmt = numDigits > 0 ? "." : ""; while (numDigits-- > 0) { fmt += "0"; } return fmt; }
Official response
Mario at GemBox
Hi,
This feature request has been implemented and is available in the latest versions of GemBox.Spreadsheet.
Regards,
Mario
Comment (1)