public int GetColumnStyle(string dataFormat) { var numberFormat = new NumberFormat { FormatCode = dataFormat, Id = 164 + NumberFormats.Count // custom number formats start from numFmtId=164 }; var cellFormat = new CellFormat { FormatId = numberFormat.Id, Id = CellFormats.Count }; NumberFormats.Add(numberFormat); CellFormats.Add(cellFormat); return cellFormat.Id; }