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

Specified NumberFormat defaulting to Date

May 20, 2013 at 5:06 PM
I am having a difficult time setting the Number Format for cells in a worksheet that has been loaded from a template.

If I try to set the Numberformat property for a cell to "#,##0.00;Red" or "#,##0.00_);(#,##0.00)" or "#,##0.00;(#,##0.00)" the result winds up formatted as a date (mm/dd/yyyy).

The method I am using to set the cell format/value in all cases is:
using (var cell = WorkSheet.Cells[rowIdx, columnIdx])
{
       cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
       cell.Style.Font.Size = 8;
       cell.Style.Numberformat.Format = "#,##0.00;[Red](#,##0.00)";
       cell.Value = <decimal/string value>;  
}
Has anyone else encountered this issue? Is there a best practice with regard to cell format setting?