public static Stylesheet UpdateStylesheet(Stylesheet styleSheet, out List <StyleIndexStruct> styleIndex) { //start add numberingFormats after 164 uint iExcelIndex = 164; var numberFormats = new NumberingFormats(); styleIndex = new List <StyleIndexStruct>(); if (styleSheet.CellFormats == null) { styleSheet.CellFormats = new CellFormats(); styleSheet.CellFormats.Count = 0; } CellFormats cellFormats = styleSheet.Elements <CellFormats>().First(); //number 0,00 CellFormat cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)2U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Decimal", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //number 0 cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)1U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); //styleIndex.Add(new StyleIndexStruct() { Name = "Number", Index = (uint)(uint)cellFormats.ChildElements.Count + 1, DisplayPattern = null }); styleIndex.Add(new StyleIndexStruct() { Name = "Number", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //text cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)49U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "Text", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //default Date cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); styleIndex.Add(new StyleIndexStruct() { Name = "DateTime", Index = (uint)cellFormats.Count++, DisplayPattern = null }); //add cellformats from displaypattern foreach (var pattern in DataTypeDisplayPattern.Pattern) { //Excel special cases //add numberFormats from displaypattern var newNumberFortmat = new NumberingFormat { NumberFormatId = UInt32Value.FromUInt32(iExcelIndex++), FormatCode = StringValue.FromString(pattern.ExcelPattern) }; numberFormats.Append(newNumberFortmat); //if (pattern.Name.Equals("DateTime")) uInt32Value = 22U; //if (pattern.Name.Equals("Date")) uInt32Value = 14U; //if (pattern.Name.Equals("Time")) uInt32Value = 21U; ///UInt32Value uInt32Value = 0U; cellFormat = new CellFormat() { NumberFormatId = newNumberFortmat.NumberFormatId, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true }; cellFormat.Protection = new Protection(); cellFormat.Protection.Locked = false; cellFormats.Append(cellFormat); DataTypeDisplayPattern tmp = new DataTypeDisplayPattern() { Name = pattern.Name, Systemtype = pattern.Systemtype, StringPattern = pattern.ExcelPattern, RegexPattern = pattern.RegexPattern }; styleIndex.Add(new StyleIndexStruct() { Name = pattern.Name, Index = (uint)cellFormats.Count++, DisplayPattern = tmp }); } styleSheet.NumberingFormats = numberFormats; return(styleSheet); }