/// <summary> /// Creates a basic stylesheet /// Can be overriden for custom cell styles /// </summary> /// <returns></returns> private Stylesheet AddStylesheet() { Stylesheet stylesheet = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } }; stylesheet.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); // create fonts Fonts fonts = new Fonts() { Count = (UInt32Value)1U, KnownFonts = true }; int fontId; var simpleFont = GetFont(new BsGridExcelStyle(), out fontId); var boldFont = GetFont(new BsGridExcelStyle() { Font = new BsGridExcelFont() { Bold = true } }, out fontId); fonts.Append(simpleFont); fonts.Append(boldFont); // create fills Fills fills = new Fills() { Count = (UInt32Value)1U }; int fillId; var noneFill = GetFill(new BsGridExcelStyle() { FillPattern = PatternValues.None }, out fillId); //needed, reserved by excel var greyFill = GetFill(new BsGridExcelStyle() { FillPattern = PatternValues.Gray125 }, out fillId); //needed, reserved by excel fills.Append(noneFill); fills.Append(greyFill); // create borders Borders borders = new Borders() { Count = (UInt32Value)1U }; var border = ExcelHelpers.CreateBorder(); borders.Append(border); // create cell style formats CellStyleFormats cellStyleFormats = new CellStyleFormats() { Count = (UInt32Value)1U }; CellFormat cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormats.Append(cellFormat); CellFormats cellFormats = new CellFormats() { Count = (UInt32Value)2U }; int formatId; CellFormat headerCellFormat = GetCellFormat(new BsGridExcelStyle { FontId = 1, FillId = 0 }, out formatId); CellFormat dataCellFormat = GetCellFormat(new BsGridExcelStyle { FontId = 0, FillId = 0 }, out formatId); cellFormats.Append(headerCellFormat); cellFormats.Append(dataCellFormat); CellStyles cellStyles = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyles.Append(cellStyle); // add to stylesheet stylesheet.Append(fonts); stylesheet.Append(fills); stylesheet.Append(borders); stylesheet.Append(cellStyleFormats); stylesheet.Append(cellFormats); stylesheet.Append(cellStyles); return(stylesheet); }