private static void CreateBasicFont(Fonts fonts, Color color) { Font font1 = new Font(); FontSize fontSize1 = new FontSize() { Val = 11D }; FontName fontName1 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor }; font1.AppendChild(fontSize1); font1.AppendChild(color); font1.AppendChild(fontName1); font1.AppendChild(fontFamilyNumbering1); font1.AppendChild(fontScheme1); fonts.AppendChild(font1); }
Fonts AddFont(Fonts fs) { Font font2 = new Font(); Bold bold1 = new Bold(); FontSize fontSize2 = new FontSize() { Val = 11D }; Color color2 = new Color() { Theme = (UInt32Value)1U }; FontName fontName2 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme2 = new FontScheme() { Val = FontSchemeValues.Minor }; font2.Append(bold1); font2.Append(fontSize2); font2.Append(color2); font2.Append(fontName2); font2.Append(fontFamilyNumbering2); font2.Append(fontScheme2); fs.Append(font2); return(fs); }
/** * set font scheme property * * @param scheme - FontScheme enum value * @see FontScheme */ public void SetScheme(FontScheme scheme) { NPOI.OpenXmlFormats.Spreadsheet.CT_FontScheme ctFontScheme = _ctFont.sizeOfSchemeArray() == 0 ? _ctFont.AddNewScheme() : _ctFont.GetSchemeArray(0); ST_FontScheme val = (ST_FontScheme)scheme.Value; ctFontScheme.val = val; }
private Font AddFont_Item() { Font fontItem = new Font(); DocumentFormat.OpenXml.Spreadsheet.FontSize fontSize = new DocumentFormat.OpenXml.Spreadsheet.FontSize() { Val = 11D }; Color color = new Color() { Rgb = new HexBinaryValue("0x000000") }; FontName fontName = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme = new FontScheme() { Val = FontSchemeValues.Minor }; fontItem.Append(fontSize); fontItem.Append(color); fontItem.Append(fontName); fontItem.Append(fontFamilyNumbering); fontItem.Append(fontScheme); return(fontItem); }
private static Font Font3() { var font = new Font(); var fontSize1 = new FontSize { Val = 13D }; var color1 = new Color { Theme = 1U }; var fontName1 = new FontName { Val = "Calibri" }; var fontFamilyNumbering1 = new FontFamilyNumbering { Val = 2 }; var fontScheme1 = new FontScheme { Val = FontSchemeValues.Minor }; var bold1 = new Bold(); // ReSharper disable PossiblyMistakenUseOfParamsMethod font.Append(bold1); font.Append(fontSize1); font.Append(color1); font.Append(fontName1); font.Append(fontFamilyNumbering1); font.Append(fontScheme1); // ReSharper restore PossiblyMistakenUseOfParamsMethod return(font); }
public void AddFont(string name, string font_family, int font_size, string color, bool isBold, string c) { var filepath = getOutputDir() + name; using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(filepath, true)) { var iter = spreadSheet.WorkbookPart.WorksheetParts.GetEnumerator(); iter.MoveNext(); var workSheetPart = iter.Current; Cell cell = InsertCellInWorksheet(GetColumnName(c), GetRowIndex(c), workSheetPart); var fs = spreadSheet.WorkbookPart.WorkbookStylesPart.Stylesheet.Fonts; var cf = spreadSheet.WorkbookPart.WorkbookStylesPart.Stylesheet.CellFormats; Font font2 = new Font(); Bold bold1 = new Bold(); FontSize fontSize2 = new FontSize() { Val = (Double)font_size }; Color color2 = new Color() { Rgb = new HexBinaryValue(color) }; FontName fontName2 = new FontName() { Val = font_family }; FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme2 = new FontScheme() { Val = FontSchemeValues.Minor }; if (isBold) { font2.Append(bold1); } font2.Append(fontSize2); font2.Append(color2); font2.Append(fontName2); font2.Append(fontFamilyNumbering2); font2.Append(fontScheme2); fs.Append(font2); CellFormat cellFormat2 = new CellFormat() { NumberFormatId = 0, FontId = (UInt32)(fs.Elements <Font>().Count() - 1), FillId = 0, BorderId = 0, FormatId = 0, ApplyFill = true }; cf.Append(cellFormat2); spreadSheet.WorkbookPart.WorkbookStylesPart.Stylesheet.Save(); cell.StyleIndex = (UInt32)(spreadSheet.WorkbookPart.WorkbookStylesPart.Stylesheet.CellFormats.Elements <CellFormat>().Count() - 1); workSheetPart.Worksheet.Save(); } }
public FontScheme GetScheme() { CT_FontScheme ctFontScheme = this._ctFont.sizeOfSchemeArray() == 0 ? (CT_FontScheme)null : this._ctFont.GetSchemeArray(0); if (ctFontScheme != null) { return(FontScheme.ValueOf((int)ctFontScheme.val)); } return(FontScheme.NONE); }
public XLFontScheme(FontScheme fontScheme) { if (fontScheme == null) { return; } MajorFont = new CollectionFont(fontScheme.MajorFont); MinorFont = new CollectionFont(fontScheme.MinorFont); Name = fontScheme.Name; }
private static void GenerateCellContentStyle(SharedStringItem shareStringItem, string font, bool isBold, bool isItalic, string str) { Run run = new Run(); RunProperties runProperties = new RunProperties(); Bold bold = new Bold(); Italic italic = new Italic(); DocumentFormat.OpenXml.Spreadsheet.FontSize fontSize = new DocumentFormat.OpenXml.Spreadsheet.FontSize() { Val = 11D }; Color color = new Color() { Theme = (UInt32Value)1U }; RunFont runFont = new RunFont() { Val = font }; FontFamily fontFamily = new FontFamily() { Val = 2 }; FontScheme fontScheme = new FontScheme() { Val = FontSchemeValues.Minor }; if (isBold) { runProperties.Append(bold); } if (isItalic) { runProperties.Append(italic); } runProperties.Append(fontSize); runProperties.Append(color); runProperties.Append(runFont); runProperties.Append(fontFamily); runProperties.Append(fontScheme); Text text1 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text1.Text = str; run.Append(runProperties); run.Append(text1); shareStringItem.Append(run); }
public void CompareFontTest() { Font x = new Font(); Font y = new Font(); FontSize size1 = new FontSize(); FontSize size2 = new FontSize(); Color color1 = new Color(); Color color2 = new Color(); FontName fontName1 = new FontName(); FontName fontName2 = new FontName(); FontFamily fontFamily1 = new FontFamily(); FontFamily fontFamily2 = new FontFamily(); FontScheme fontScheme1 = new FontScheme(); FontScheme fontScheme2 = new FontScheme(); color1.Rgb = "FFFF0000"; color2.Rgb = "FFFF0000"; size1.Val = 12; size2.Val = 12; fontName1.Val = "Calibri"; fontName2.Val = "Calibri"; fontFamily1.Val = 2; fontFamily2.Val = 2; fontScheme1.Val = FontSchemeValues.Minor; fontScheme2.Val = FontSchemeValues.Minor; x.AppendChild <Italic>(new Italic()); x.AppendChild <FontSize>(size1); x.AppendChild <Color>(color1); x.AppendChild <FontName>(fontName1); x.AppendChild <FontFamily>(fontFamily1); x.AppendChild <FontScheme>(fontScheme1); y.AppendChild <Italic>(new Italic()); y.AppendChild <FontSize>(size2); y.AppendChild <Color>(color2); y.AppendChild <FontName>(fontName2); y.AppendChild <FontFamily>(fontFamily2); y.AppendChild <FontScheme>(fontScheme2); //check they match Assert.IsTrue(SpreadsheetStyle.CompareFont(x, y), "Equal fonts do not compare."); //change a value size2.Val = 13; Assert.IsFalse(SpreadsheetStyle.CompareFont(x, y), "Unequal fonts do compare."); }
public FontScheme ToExcelFontScheme() { var majorFont = new MajorFont(); MajorFont.FillExcelCollectionFont(majorFont); var minorFont = new MinorFont(); MinorFont.FillExcelCollectionFont(minorFont); var fontScheme = new FontScheme { Name = string.IsNullOrWhiteSpace(Name) ? "Office" : Name }; fontScheme.AppendChild(majorFont); fontScheme.AppendChild(minorFont); return(fontScheme); }
private void AppendDefaultFonts(Stylesheet stylesheet) { var fonts = new Fonts() { Count = (UInt32Value)1U, KnownFonts = true }; var font = new Font(); var fontSize = new FontSize() { Val = 11D }; var color = new Color() { Theme = (UInt32Value)1U }; var fontName = new FontName() { Val = "Calibri" }; var fontFamilyNumbering = new FontFamilyNumbering() { Val = 2 }; var fontCharSet = new FontCharSet() { Val = 204 }; var fontScheme = new FontScheme() { Val = FontSchemeValues.Minor }; font.Append(fontSize); font.Append(color); font.Append(fontName); font.Append(fontFamilyNumbering); font.Append(fontCharSet); font.Append(fontScheme); fonts.Append(font); stylesheet.Append(fonts); }
/// <summary> /// Меняет начертание текста ячейки на полужирное /// </summary> /// <param name="sheetName">Имя листа, содержащего редактируемую ячейку</param> /// <param name="columnName">Адрес ячейки, имя столбца</param> /// <param name="rowIndex">Адрес ячейки, номер строки</param> public void MakeBold(string sheetName, string columnName, uint rowIndex) { GetSpreadSheet(sheetName); Cell cell = GetCell(columnName, rowIndex); CellFormat cellFormat = GetOrCreateCellFormat(cell); Font font = new Font(); Bold bold = new Bold(); FontSize fontSize = new FontSize() { Val = 11D }; Color color = new Color() { Theme = 1U }; FontName name = new FontName() { Val = "Calibri" }; FontFamilyNumbering numbering = new FontFamilyNumbering() { Val = 2 }; FontScheme scheme = new FontScheme() { Val = FontSchemeValues.Minor }; font.Append(bold); font.Append(fontSize); font.Append(color); font.Append(name); font.Append(numbering); font.Append(scheme); cellFormat.FontId = InsertFont(font); cellFormat.ApplyFont = true; cell.StyleIndex = InsertCellFormat(cellFormat); }
///<summary> ///Returns a new Font object from the style information provided ///</summary> public Font ToFont() { Font font = new Font(); if (Italic != null) { font.AppendChild <Italic>(new Italic()); } if (Bold != null) { font.AppendChild <Bold>(new Bold()); } if (Underline != null) { font.AppendChild <Underline>(new Underline()); } if (Color != null) { font.AppendChild <Color>(Color.CloneElement <Color>()); } if (FontSize != null) { font.AppendChild <FontSize>(FontSize.CloneElement <FontSize>()); } if (FontName != null) { font.AppendChild <FontName>(FontName.CloneElement <FontName>()); } if (FontFamily != null) { font.AppendChild <FontFamily>(FontFamily.CloneElement <FontFamily>()); } if (FontScheme != null) { font.AppendChild <FontScheme>(FontScheme.CloneElement <FontScheme>()); } return(font); }
public static void Run() { // ExStart:1 SlidesApi slidesApi = new SlidesApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); String fileName = "demo.pptx"; int slideIndex = 1; String folder = ""; String storage = ""; try { // Upload source file to aspose cloud storage storageApi.PutCreate(fileName, "", "", System.IO.File.ReadAllBytes(Common.GetDataDir() + fileName)); // Invoke Aspose.Slides Cloud SDK API to get slide font scheme FontSchemeResponse apiResponse = slidesApi.GetSlidesThemeFontScheme(fileName, slideIndex, folder, storage); if (apiResponse != null && apiResponse.Status.Equals("OK")) { FontScheme fontScheme = apiResponse.FontScheme; Console.WriteLine("Name: " + fontScheme.Name); Console.WriteLine("ComplexScript (heading part) : " + fontScheme.Major.ComplexScript); Console.WriteLine("EastAsian (heading part) : " + fontScheme.Major.EastAsian); Console.WriteLine("Latin (heading part) : " + fontScheme.Major.Latin); Console.WriteLine("ComplexScript (body part) : " + fontScheme.Minor.ComplexScript); Console.WriteLine("EastAsian (body part) : " + fontScheme.Minor.EastAsian); Console.WriteLine("Latin (body part) : " + fontScheme.Minor.Latin); Console.WriteLine("Get Font Scheme of a PowerPoint Slide, Done!"); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
public static bool Compare(this FontScheme thisValue, FontScheme fontScheme) { if (ExclusiveNull(thisValue, fontScheme)) { return(false); } if (AreNull(thisValue, fontScheme)) { return(true); } if (ExclusiveHasValue(thisValue.Val, fontScheme.Val)) { return(false); } if (AreNullValue(thisValue.Val, fontScheme.Val)) { return(true); } return(thisValue.Val.Value == fontScheme.Val.Value); }
public void ReadFontFamilyFromTheme(LatinFont latinFonts) { FontScheme allSchemeFonts = slide.SlideLayoutPart.SlideMasterPart.ThemePart.Theme .ThemeElements.FontScheme; var minorFont = allSchemeFonts.GetFirstChild <MinorFont>(); var majorFont = allSchemeFonts.GetFirstChild <MajorFont>(); if (latinFonts != null) { FontFamily = latinFonts.Typeface.Value; if (latinFonts.Typeface.Value.Equals("+mj-lt")) { FontFamily = majorFont.LatinFont.Typeface.Value; } else if (latinFonts.Typeface.Value.Equals("+mj-cs")) { FontFamily = majorFont.ComplexScriptFont.Typeface.Value; } else if (latinFonts.Typeface.Value.Equals("+mj-ea")) { FontFamily = majorFont.EastAsianFont.Typeface.Value; } else if (latinFonts.Typeface.Value.Equals("+mn-lt")) { FontFamily = minorFont.LatinFont.Typeface.Value; } else if (latinFonts.Typeface.Value.Equals("+mn-cs")) { FontFamily = minorFont.ComplexScriptFont.Typeface.Value; } else if (latinFonts.Typeface.Value.Equals("+mn-ea")) { FontFamily = minorFont.EastAsianFont.Typeface.Value; } } }
private Font AddFont_Header() { Font fontHeader = new Font(); Bold bold = new Bold(); DocumentFormat.OpenXml.Spreadsheet.FontSize fontSize = new DocumentFormat.OpenXml.Spreadsheet.FontSize() { Val = 12D }; Color color = new Color() { Rgb = new HexBinaryValue("0x00660a") }; FontName fontName = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme = new FontScheme() { Val = FontSchemeValues.Minor }; fontHeader.Append(bold); fontHeader.Append(fontSize); fontHeader.Append(color); fontHeader.Append(fontName); fontHeader.Append(fontFamilyNumbering); fontHeader.Append(fontScheme); //fs.Append(fontHeader); return(fontHeader); }
private static Stylesheet CreateStylesheet() { // Stylesheet declarion and namespace 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"); // List of fonts Fonts fontsList = new Fonts() { Count = (UInt32Value)2U, KnownFonts = true }; // FontId=0 - Regular Excel font Font font0 = new Font(); FontSize fontSize0 = new FontSize() { Val = 11D }; Color color0 = new Color() { Theme = (UInt32Value)1U }; FontName fontName0 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering0 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme0 = new FontScheme() { Val = FontSchemeValues.Minor }; font0.Append(fontSize0); font0.Append(color0); font0.Append(fontName0); font0.Append(fontFamilyNumbering0); font0.Append(fontScheme0); // FontId=1 - Bold font for header Font font1 = new Font(); Bold bold = new Bold(); font1.Append(bold); fontsList.Append(font0); fontsList.Append(font1); // List of fills Fills fillList = new Fills() { Count = (UInt32Value)3U }; // FillId = 0, Normal background Fill fill0 = new Fill(); PatternFill patternFill0 = new PatternFill() { PatternType = PatternValues.None }; fill0.Append(patternFill0); // FillId = 00, Normal background Fill fill00 = new Fill(); PatternFill patternFill00 = new PatternFill() { PatternType = PatternValues.None }; fill00.Append(patternFill00); // FillId = 1, Light Blue for alternating cells Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor1 = new ForegroundColor() { Rgb = "FFDEEFF7" }; patternFill1.Append(foregroundColor1); fill1.Append(patternFill1); fillList.Append(fill0); fillList.Append(fill00); fillList.Append(fill1); // Borders style Borders bordersList = new Borders() { Count = (UInt32Value)1U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); bordersList.Append(border1); // List of cell styles formats CellStyleFormats cellStyleFormatsList = new CellStyleFormats() { Count = (UInt32Value)1U }; CellFormat cellFormat = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormatsList.Append(cellFormat); // Cells formats CellFormats cellFormatsList = new CellFormats() { Count = (UInt32Value)5U }; // StyleIndex = 0 - Regular font CellFormat cellFormat0 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // StyleIndex = 1 - Bold font CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // StyleIndex = 2 - Date (Short Date) CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // StyleIndex = 3 - Light blue background (Text and Numbers) CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true }; // StyleIndex = 4 - Light blue background (Date) CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true }; cellFormatsList.Append(cellFormat0); cellFormatsList.Append(cellFormat1); cellFormatsList.Append(cellFormat2); cellFormatsList.Append(cellFormat3); cellFormatsList.Append(cellFormat4); // Cells styles CellStyles cellStyleList = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle0 = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyleList.Append(cellStyle0); DifferentialFormats differentialFormats0 = new DifferentialFormats() { Count = (UInt32Value)0U }; TableStyles tableStyles0 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleMedium9" }; StylesheetExtensionList stylesheetExtensionList = new StylesheetExtensionList(); StylesheetExtension stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtensionList.Append(stylesheetExtension1); stylesheet.Append(fontsList); stylesheet.Append(fillList); stylesheet.Append(bordersList); stylesheet.Append(cellStyleFormatsList); stylesheet.Append(cellFormatsList); stylesheet.Append(cellStyleList); stylesheet.Append(differentialFormats0); stylesheet.Append(tableStyles0); stylesheet.Append(stylesheetExtensionList); return(stylesheet); }
/// <summary> /// Generates content of workbookStylesPart /// </summary> /// <param name="workbookStylesPart">WorkbookStylesPart Object</param> private void CreateWorkBookStylesPart(WorkbookStylesPart workbookStylesPart) { // Define Style of Sheet in workbook Stylesheet stylesheet1 = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); // Initialize an instance of fonts Fonts fonts = new Fonts() { Count = (UInt32Value)2U, KnownFonts = true }; // Initialize an instance of font,fontsize,color Font font = new Font(); FontSize fontSize = new FontSize() { Val = 14D }; Color color = new Color() { Theme = (UInt32Value)1U }; FontName fontName = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme = new FontScheme() { Val = FontSchemeValues.Minor }; // Add elements to font font.Append(fontSize); font.Append(color); font.Append(fontName); font.Append(fontFamilyNumbering); font.Append(fontScheme); fonts.Append(font); // Define the StylesheetExtensionList Class. When the object is serialized out as xml, its qualified name is x:extLst StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList(); // Define the StylesheetExtension Class StylesheetExtension stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles slicerStyles1 = new DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" }; stylesheetExtension1.Append(slicerStyles1); stylesheetExtensionList1.Append(stylesheetExtension1); // Add elements to stylesheet stylesheet1.Append(fonts); stylesheet1.Append(stylesheetExtensionList1); // Set the style of workbook workbookStylesPart.Stylesheet = stylesheet1; }
/** * get the font scheme property. * is used only in StylesTable to create the default instance of font * * @return FontScheme * @see NPOI.XSSF.model.StylesTable#CreateDefaultFont() */ public FontScheme GetScheme() { NPOI.OpenXmlFormats.Spreadsheet.CT_FontScheme scheme = _ctFont.sizeOfSchemeArray() == 0 ? null : _ctFont.GetSchemeArray(0); return(scheme == null ? FontScheme.NONE : FontScheme.ValueOf((int)scheme.val)); }
public static Stylesheet GenerateStylesheet() { Stylesheet stylesheet1 = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); Fonts fonts1 = new Fonts() { Count = (UInt32Value)3U, KnownFonts = true }; Font font1 = new Font(); FontSize fontSize1 = new FontSize() { Val = 14D }; Color color1 = new Color() { Theme = (UInt32Value)1U }; FontName fontName1 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); Font font2 = new Font(); Bold bold2 = new Bold(); FontSize fontSize2 = new FontSize() { Val = 18D }; Color color2 = new Color() { Theme = (UInt32Value)1U }; FontName fontName2 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme2 = new FontScheme() { Val = FontSchemeValues.Minor }; font2.Append(bold2); font2.Append(fontSize2); font2.Append(color2); font2.Append(fontName2); font2.Append(fontFamilyNumbering2); font2.Append(fontScheme2); Font font3 = new Font(); Bold bold1 = new Bold(); FontSize fontSize3 = new FontSize() { Val = 30D }; Color color3 = new Color() { Theme = (UInt32Value)1U }; FontName fontName3 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering3 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme3 = new FontScheme() { Val = FontSchemeValues.Minor }; font3.Append(bold1); font3.Append(fontSize3); font3.Append(color3); font3.Append(fontName3); font3.Append(fontFamilyNumbering3); font3.Append(fontScheme3); fonts1.Append(font1); fonts1.Append(font2); fonts1.Append(font3); Fills fills1 = new Fills() { Count = (UInt32Value)2U }; // 0 no BG color just normal Excel Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None }; fill1.Append(patternFill1); // 1 red or open CAT 1 Fill fill2 = new Fill(); PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor2 = new ForegroundColor() { Rgb = "FFFF0000" }; BackgroundColor backgroundColor2 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill2.Append(foregroundColor2); patternFill2.Append(backgroundColor2); fill2.Append(patternFill2); // 2 silver or N/A Fill fill3 = new Fill(); PatternFill patternFill3 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor3 = new ForegroundColor() { Rgb = "FFCCCCCC" }; BackgroundColor backgroundColor3 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill3.Append(foregroundColor3); patternFill3.Append(backgroundColor3); fill3.Append(patternFill3); // 3 green or NaF Fill fill4 = new Fill(); PatternFill patternFill4 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor4 = new ForegroundColor() { Rgb = "FF50CC83" }; BackgroundColor backgroundColor4 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill4.Append(foregroundColor4); patternFill4.Append(backgroundColor4); fill4.Append(patternFill4); // 4 black&white or Not Reviewed Fill fill5 = new Fill(); PatternFill patternFill5 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor5 = new ForegroundColor() { Rgb = "FFFFFFFF" }; BackgroundColor backgroundColor5 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill5.Append(foregroundColor5); patternFill5.Append(backgroundColor5); fill5.Append(patternFill5); // 5 red or open CAT 1 Fill fill6 = new Fill(); PatternFill patternFill6 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor6 = new ForegroundColor() { Rgb = "FFE53935" }; BackgroundColor backgroundColor6 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill6.Append(foregroundColor6); patternFill6.Append(backgroundColor6); fill6.Append(patternFill6); // 6 orange open CAT 2 Fill fill7 = new Fill(); PatternFill patternFill7 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor7 = new ForegroundColor() { Rgb = "FFFFA500" }; BackgroundColor backgroundColor7 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill7.Append(foregroundColor7); patternFill7.Append(backgroundColor7); fill7.Append(patternFill7); // 7 orange open CAT 3 Fill fill8 = new Fill(); PatternFill patternFill8 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor8 = new ForegroundColor() { Rgb = "FFD8D80E" }; BackgroundColor backgroundColor8 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill8.Append(foregroundColor8); patternFill8.Append(backgroundColor8); fill8.Append(patternFill8); // 8 gray background for any general use Fill fill9 = new Fill(); PatternFill patternFill9 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor9 = new ForegroundColor() { Rgb = "FFBBBBBB" }; BackgroundColor backgroundColor9 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill9.Append(foregroundColor9); patternFill9.Append(backgroundColor9); fill9.Append(patternFill9); fills1.Append(fill1); // these are 0 based when you include in the CellFormat statements below, so 1 off fills1.Append(fill2); fills1.Append(fill3); fills1.Append(fill4); fills1.Append(fill5); fills1.Append(fill6); fills1.Append(fill7); fills1.Append(fill8); fills1.Append(fill9); Borders borders1 = new Borders() { Count = (UInt32Value)1U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); borders1.Append(border1); CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = (UInt32Value)1U }; CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormats1.Append(cellFormat1); CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)4U }; // style index 0: normal font and wrapping of text for cell rows CellFormat cellFormat2 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 1: normal font with numerical format CellFormat cellFormat3 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)2U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true }; // style index 2: title font of 30 bold CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true }; // style index 3: info row under title and header rows font bold size 18 CellFormat cellFormat5 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true }; // fill colors based on the fillx variables above to match the 4 statuses of the checklist vulnerabilities // style index 4: red or Open CellFormat cellFormat6 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)5U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 5: silver or Not Applicable CellFormat cellFormat7 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 6: green or Not a Finding CellFormat cellFormat8 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 7: b/w or Not Reviewed CellFormat cellFormat9 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)4U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // CENTER The content for listings versus the excel export of a checklist above // style index 8: red or Open centered content CellFormat cellFormat10 = new CellFormat(new Alignment() { WrapText = true, Horizontal = HorizontalAlignmentValues.Center }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)5U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 9: silver or Not Applicable CellFormat cellFormat11 = new CellFormat(new Alignment() { WrapText = true, Horizontal = HorizontalAlignmentValues.Center }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 10: green or Not a Finding CellFormat cellFormat12 = new CellFormat(new Alignment() { WrapText = true, Horizontal = HorizontalAlignmentValues.Center }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 11: b/w or Not Reviewed CellFormat cellFormat13 = new CellFormat(new Alignment() { WrapText = true, Horizontal = HorizontalAlignmentValues.Center }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)4U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 12: orange Open CAT 2 CellFormat cellFormat14 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)6U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 13: yellow Open CAT 3 CellFormat cellFormat15 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)7U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 14: orange Open CAT 2 centered CellFormat cellFormat16 = new CellFormat(new Alignment() { WrapText = true, Horizontal = HorizontalAlignmentValues.Center }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)6U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 15: yellow Open CAT 3 centered CellFormat cellFormat17 = new CellFormat(new Alignment() { WrapText = true, Horizontal = HorizontalAlignmentValues.Center }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)7U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; // style index 16: yellow Open CAT 3 centered CellFormat cellFormat18 = new CellFormat(new Alignment() { WrapText = true }) { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)8U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true }; // add all these formats cellFormats1.Append(cellFormat2); cellFormats1.Append(cellFormat3); cellFormats1.Append(cellFormat4); cellFormats1.Append(cellFormat5); cellFormats1.Append(cellFormat6); cellFormats1.Append(cellFormat7); cellFormats1.Append(cellFormat8); cellFormats1.Append(cellFormat9); cellFormats1.Append(cellFormat10); cellFormats1.Append(cellFormat11); cellFormats1.Append(cellFormat12); cellFormats1.Append(cellFormat13); cellFormats1.Append(cellFormat14); cellFormats1.Append(cellFormat15); cellFormats1.Append(cellFormat16); cellFormats1.Append(cellFormat17); cellFormats1.Append(cellFormat18); CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle1 = new CellStyle() { Name = "Normal", FormatId = 0, BuiltinId = 0 }; cellStyles1.Append(cellStyle1); DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = 0 }; TableStyles tableStyles1 = new TableStyles() { Count = 0, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList(); StylesheetExtension stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); StylesheetExtension stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" }; stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); stylesheetExtensionList1.Append(stylesheetExtension1); stylesheetExtensionList1.Append(stylesheetExtension2); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); stylesheet1.Append(cellStyles1); stylesheet1.Append(differentialFormats1); stylesheet1.Append(tableStyles1); stylesheet1.Append(stylesheetExtensionList1); return(stylesheet1); }
// Generates content of workbookStylesPart1. private void GenerateWorkbookStylesPart1Content(WorkbookStylesPart workbookStylesPart1) { Stylesheet stylesheet1 = new Stylesheet(); Fonts fonts1 = new Fonts() { Count = (UInt32Value)1U, KnownFonts = true }; Font font1 = new Font(); FontSize fontSize1 = new FontSize() { Val = 11D }; Color color1 = new Color() { Theme = (UInt32Value)1U }; FontName fontName1 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); fonts1.Append(font1); Fills fills1 = new Fills() { Count = (UInt32Value)2U }; Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None }; fill1.Append(patternFill1); Fill fill2 = new Fill(); PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Gray125 }; fill2.Append(patternFill2); fills1.Append(fill1); fills1.Append(fill2); Borders borders1 = new Borders() { Count = (UInt32Value)1U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); borders1.Append(border1); CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = (UInt32Value)1U }; CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormats1.Append(cellFormat1); CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)4U }; CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true }; CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, PivotButton = true }; CellFormat cellFormat5 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyAlignment = true }; cellFormats1.Append(cellFormat2); cellFormats1.Append(cellFormat3); cellFormats1.Append(cellFormat4); cellFormats1.Append(cellFormat5); CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle1 = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyles1.Append(cellStyle1); DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = (UInt32Value)0U }; stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); stylesheet1.Append(cellStyles1); stylesheet1.Append(differentialFormats1); workbookStylesPart1.Stylesheet = stylesheet1; }
private uint GenerateStylesheet() { WorksheetPart worksheetPart = workbookPart.AddNewPart <WorksheetPart>(); worksheetPart.Worksheet = new Worksheet(); WorkbookStylesPart workbookStylesPart1 = workbookPart.AddNewPart <WorkbookStylesPart>(); Stylesheet stylesheet1 = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac x16r2 xr" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); stylesheet1.AddNamespaceDeclaration("x16r2", "http://schemas.microsoft.com/office/spreadsheetml/2015/02/main"); stylesheet1.AddNamespaceDeclaration("xr", "http://schemas.microsoft.com/office/spreadsheetml/2014/revision"); Fonts fonts1 = new Fonts() { Count = 1U, KnownFonts = true }; Font font1 = new Font(); FontSize fontSize1 = new FontSize() { Val = 11D }; Color color1 = new Color() { Theme = 1U }; FontName fontName1 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); fonts1.Append(font1); Fills fills1 = new Fills() { Count = 1U }; Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None }; fill1.Append(patternFill1); fills1.Append(fill1); Borders borders1 = new Borders() { Count = 0U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); borders1.Append(border1); CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = 1U }; CellFormat cellFormat1 = new CellFormat() { NumberFormatId = 0U }; cellStyleFormats1.Append(cellFormat1); CellFormats cellFormats1 = new CellFormats() { Count = 2U }; CellFormat cellFormat43 = new CellFormat() { NumberFormatId = 0U, FormatId = 0U }; CellFormat cellFormat44 = new CellFormat() { NumberFormatId = 14U, FormatId = 0U, ApplyNumberFormat = true }; cellFormats1.Append(cellFormat43); cellFormats1.Append(cellFormat44); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); workbookStylesPart1.Stylesheet = stylesheet1; return(1); }
public SpreadsheetStylesManager(WorkbookPart workbookPart) { _workbookPart = workbookPart; _styles = new Dictionary <string, int>(); _fonts = new Dictionary <FontKey, int>(); _fills = new Dictionary <System.Drawing.Color, int>(); var stylesPart = _workbookPart.AddNewPart <WorkbookStylesPart>(); _stylesheet = new Stylesheet(); stylesPart.Stylesheet = _stylesheet; _stylesheet.Fills = new Fills(); _stylesheet.Fills.AppendChild(new Fill { PatternFill = new PatternFill { PatternType = PatternValues.None } }); // required, reserved by Excel _stylesheet.Fills.AppendChild(new Fill { PatternFill = new PatternFill { PatternType = PatternValues.Gray125 } }); // required, reserved by Excel _stylesheet.Fills.Count = 2; stylesPart.Stylesheet.Fonts = new Fonts(); stylesPart.Stylesheet.Fonts.Count = 2; stylesPart.Stylesheet.Fonts.AppendChild(new Font()); Font hyperLinkFont = new Font(); Underline underline1 = new Underline(); FontSize fontSize2 = new FontSize() { Val = 11D }; Color color2 = new Color() { Theme = (UInt32Value)10U }; FontName fontName2 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering() { Val = 2 }; FontCharSet fontCharSet2 = new FontCharSet() { Val = 238 }; FontScheme fontScheme2 = new FontScheme() { Val = FontSchemeValues.Minor }; hyperLinkFont.Append(underline1); hyperLinkFont.Append(fontSize2); hyperLinkFont.Append(color2); hyperLinkFont.Append(fontName2); hyperLinkFont.Append(fontFamilyNumbering2); hyperLinkFont.Append(fontCharSet2); hyperLinkFont.Append(fontScheme2); stylesPart.Stylesheet.Fonts.AppendChild(hyperLinkFont); stylesPart.Stylesheet.Borders = new Borders(); stylesPart.Stylesheet.Borders.Count = 1; stylesPart.Stylesheet.Borders.AppendChild(new Border()); stylesPart.Stylesheet.CellStyleFormats = new CellStyleFormats(); stylesPart.Stylesheet.CellStyleFormats.Count = 2; stylesPart.Stylesheet.CellStyleFormats.AppendChild(new CellFormat()); stylesPart.Stylesheet.CellFormats = new CellFormats(); // empty one for index 0, seems to be required stylesPart.Stylesheet.CellFormats.AppendChild(new CellFormat()); CellFormat hyperLinkFormt = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, ApplyNumberFormat = false, ApplyFill = false, ApplyBorder = false, ApplyAlignment = false, ApplyProtection = false }; stylesPart.Stylesheet.CellFormats.AppendChild(hyperLinkFormt); stylesPart.Stylesheet.CellFormats.Count = 2; _hyperlinkStyles[new SpreadsheetStyle().GetIdentifier()] = 1; Borders borders = new Borders() { Count = (UInt32Value)1U }; Border border = new Border(); LeftBorder leftBorder = new LeftBorder(); RightBorder rightBorder = new RightBorder(); TopBorder topBorder = new TopBorder(); BottomBorder bottomBorder = new BottomBorder(); DiagonalBorder diagonalBorder = new DiagonalBorder(); border.AppendChild(leftBorder); border.AppendChild(rightBorder); border.AppendChild(topBorder); border.AppendChild(bottomBorder); border.AppendChild(diagonalBorder); borders.AppendChild(border); _stylesheet.Borders = borders; CellStyles cellStyles = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyles.AppendChild(cellStyle); _stylesheet.CellStyles = cellStyles; var dateTimeFormatInfo = DateTimeFormatInfo.CurrentInfo; var dateTimeFormat = "d.mm.yyyy hh:mm:ss"; if (dateTimeFormatInfo != null) { dateTimeFormat = dateTimeFormatInfo.ShortDatePattern + " " + dateTimeFormatInfo.LongTimePattern; dateTimeFormat = dateTimeFormat.Replace("/", "\\/"); dateTimeFormat = dateTimeFormat.Replace("tt", "AM/PM"); } NumberingFormats numberingFormats = new NumberingFormats() { Count = (UInt32Value)1U }; NumberingFormat numberingFormat1 = new NumberingFormat() { NumberFormatId = (UInt32Value)164U, FormatCode = dateTimeFormat }; numberingFormats.Append(numberingFormat1); _stylesheet.NumberingFormats = numberingFormats; }
protected InlineString FormatMessage(string value, string cellReference) { var returnObject = new InlineString(); var anchors = Anchor.Find(value); if (!anchors.Any()) { returnObject.Append(new Run(new Text(value.TrimEnd(Environment.NewLine.ToCharArray())) { Space = SpaceProcessingModeValues.Preserve })); } else { // Use the first instance because only one hyperlink per cell is allowed var anchor = anchors[0]; var hyperLinkId = string.Concat(cellReference, "HyperLink"); WorksheetPart.AddHyperlinkRelationship(new System.Uri(anchor.Href, System.UriKind.Absolute), true, hyperLinkId); Hyperlinks.Append(new Hyperlink() { Reference = cellReference, Id = hyperLinkId }); // The entire cell will be a hyperlink but only the anchor text will look like a link var valueWithoutAnchor = value.Replace(anchor.Value, string.Empty).TrimEnd('.').TrimEnd(Environment.NewLine.ToCharArray()); Run run1 = new Run(); RunProperties runProperties1 = new RunProperties(); FontSize fontSize3 = new FontSize() { Val = 11D }; Color color3 = new Color() { Theme = (UInt32Value)1U }; RunFont runFont1 = new RunFont() { Val = "Calibri" }; FontFamily fontFamily1 = new FontFamily() { Val = 2 }; FontScheme fontScheme4 = new FontScheme() { Val = FontSchemeValues.Minor }; runProperties1.Append(fontSize3); runProperties1.Append(color3); runProperties1.Append(runFont1); runProperties1.Append(fontFamily1); runProperties1.Append(fontScheme4); Text text1 = new Text(); text1.Text = valueWithoutAnchor; text1.Space = SpaceProcessingModeValues.Preserve; run1.Append(runProperties1); run1.Append(text1); Run run2 = new Run(); RunProperties runProperties2 = new RunProperties(); Underline underline2 = new Underline(); FontSize fontSize4 = new FontSize() { Val = 11D }; Color color4 = new Color() { Theme = (UInt32Value)10U }; RunFont runFont2 = new RunFont() { Val = "Calibri" }; FontFamily fontFamily2 = new FontFamily() { Val = 2 }; FontScheme fontScheme5 = new FontScheme() { Val = FontSchemeValues.Minor }; runProperties2.Append(underline2); runProperties2.Append(fontSize4); runProperties2.Append(color4); runProperties2.Append(runFont2); runProperties2.Append(fontFamily2); runProperties2.Append(fontScheme5); Text text2 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text2.Text = string.Concat(anchor.Text, "."); run2.Append(runProperties2); run2.Append(text2); returnObject.Append(run1); returnObject.Append(run2); } return(returnObject); }
// Creates an Stylesheet instance and adds its children. public static Stylesheet GenerateStylesheet() { var stylesheet1 = new Stylesheet {MCAttributes = new MarkupCompatibilityAttributes {Ignorable = "x14ac"}}; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); var fonts1 = new Fonts {Count = 7U, KnownFonts = true}; var font1 = new Font(); var fontSize1 = new FontSize {Val = 11D}; var color1 = new Color {Theme = 1U}; var fontName1 = new FontName {Val = "Calibri"}; var fontFamilyNumbering1 = new FontFamilyNumbering {Val = 2}; var fontCharSet1 = new FontCharSet {Val = 204}; var fontScheme1 = new FontScheme {Val = FontSchemeValues.Minor}; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontCharSet1); font1.Append(fontScheme1); var font2 = new Font(); var bold1 = new Bold(); var fontSize2 = new FontSize {Val = 11D}; var color2 = new Color {Theme = 1U}; var fontName2 = new FontName {Val = "Calibri"}; var fontFamilyNumbering2 = new FontFamilyNumbering {Val = 2}; var fontCharSet2 = new FontCharSet {Val = 204}; var fontScheme2 = new FontScheme {Val = FontSchemeValues.Minor}; font2.Append(bold1); font2.Append(fontSize2); font2.Append(color2); font2.Append(fontName2); font2.Append(fontFamilyNumbering2); font2.Append(fontCharSet2); font2.Append(fontScheme2); var font3 = new Font(); var bold2 = new Bold(); var italic1 = new Italic(); var fontSize3 = new FontSize {Val = 11D}; var color3 = new Color {Theme = 1U}; var fontName3 = new FontName {Val = "Calibri"}; var fontFamilyNumbering3 = new FontFamilyNumbering {Val = 2}; var fontCharSet3 = new FontCharSet {Val = 204}; var fontScheme3 = new FontScheme {Val = FontSchemeValues.Minor}; font3.Append(bold2); font3.Append(italic1); font3.Append(fontSize3); font3.Append(color3); font3.Append(fontName3); font3.Append(fontFamilyNumbering3); font3.Append(fontCharSet3); font3.Append(fontScheme3); var font4 = new Font(); var bold3 = new Bold(); var fontSize4 = new FontSize {Val = 18D}; var color4 = new Color {Theme = 1U}; var fontName4 = new FontName {Val = "Calibri"}; var fontFamilyNumbering4 = new FontFamilyNumbering {Val = 2}; var fontCharSet4 = new FontCharSet {Val = 204}; var fontScheme4 = new FontScheme {Val = FontSchemeValues.Minor}; font4.Append(bold3); font4.Append(fontSize4); font4.Append(color4); font4.Append(fontName4); font4.Append(fontFamilyNumbering4); font4.Append(fontCharSet4); font4.Append(fontScheme4); var font5 = new Font(); var bold4 = new Bold(); var fontSize5 = new FontSize {Val = 11D}; var fontName5 = new FontName {Val = "Calibri"}; var fontFamilyNumbering5 = new FontFamilyNumbering {Val = 2}; var fontCharSet5 = new FontCharSet {Val = 204}; var fontScheme5 = new FontScheme {Val = FontSchemeValues.Minor}; font5.Append(bold4); font5.Append(fontSize5); font5.Append(fontName5); font5.Append(fontFamilyNumbering5); font5.Append(fontCharSet5); font5.Append(fontScheme5); var font6 = new Font(); var fontSize6 = new FontSize {Val = 11D}; var fontName6 = new FontName {Val = "Calibri"}; var fontFamilyNumbering6 = new FontFamilyNumbering {Val = 2}; var fontCharSet6 = new FontCharSet {Val = 204}; var fontScheme6 = new FontScheme {Val = FontSchemeValues.Minor}; font6.Append(fontSize6); font6.Append(fontName6); font6.Append(fontFamilyNumbering6); font6.Append(fontCharSet6); font6.Append(fontScheme6); var font7 = new Font(); var bold5 = new Bold(); var fontSize7 = new FontSize {Val = 12D}; var color5 = new Color {Theme = 1U}; var fontName7 = new FontName {Val = "Calibri"}; var fontFamilyNumbering7 = new FontFamilyNumbering {Val = 2}; var fontCharSet7 = new FontCharSet {Val = 204}; var fontScheme7 = new FontScheme {Val = FontSchemeValues.Minor}; font7.Append(bold5); font7.Append(fontSize7); font7.Append(color5); font7.Append(fontName7); font7.Append(fontFamilyNumbering7); font7.Append(fontCharSet7); font7.Append(fontScheme7); fonts1.Append(font1); fonts1.Append(font2); fonts1.Append(font3); fonts1.Append(font4); fonts1.Append(font5); fonts1.Append(font6); fonts1.Append(font7); var fills1 = new Fills {Count = 2U}; var fill1 = new Fill(); var patternFill1 = new PatternFill {PatternType = PatternValues.None}; fill1.Append(patternFill1); var fill2 = new Fill(); var patternFill2 = new PatternFill {PatternType = PatternValues.Gray125}; fill2.Append(patternFill2); fills1.Append(fill1); fills1.Append(fill2); var borders1 = new Borders {Count = 2U}; var border1 = new Border(); var leftBorder1 = new LeftBorder(); var rightBorder1 = new RightBorder(); var topBorder1 = new TopBorder(); var bottomBorder1 = new BottomBorder(); var diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); var border2 = new Border(); var leftBorder2 = new LeftBorder {Style = BorderStyleValues.Thin}; var color6 = new Color {Indexed = 64U}; leftBorder2.Append(color6); var rightBorder2 = new RightBorder {Style = BorderStyleValues.Thin}; var color7 = new Color {Indexed = 64U}; rightBorder2.Append(color7); var topBorder2 = new TopBorder {Style = BorderStyleValues.Thin}; var color8 = new Color {Indexed = 64U}; topBorder2.Append(color8); var bottomBorder2 = new BottomBorder {Style = BorderStyleValues.Thin}; var color9 = new Color {Indexed = 64U}; bottomBorder2.Append(color9); var diagonalBorder2 = new DiagonalBorder(); border2.Append(leftBorder2); border2.Append(rightBorder2); border2.Append(topBorder2); border2.Append(bottomBorder2); border2.Append(diagonalBorder2); borders1.Append(border1); borders1.Append(border2); var cellStyleFormats1 = new CellStyleFormats {Count = 4U}; var cellFormat1 = new CellFormat {NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U}; var cellFormat2 = new CellFormat { NumberFormatId = 0U, FontId = 5U, FillId = 0U, BorderId = 1U, ApplyNumberFormat = false, ApplyAlignment = false, ApplyProtection = false }; var cellFormat3 = new CellFormat { NumberFormatId = 0U, FontId = 4U, FillId = 0U, BorderId = 1U, ApplyNumberFormat = false, ApplyAlignment = false, ApplyProtection = false }; var cellFormat4 = new CellFormat {NumberFormatId = 0U, FontId = 6U, FillId = 0U, BorderId = 1U}; cellStyleFormats1.Append(cellFormat1); cellStyleFormats1.Append(cellFormat2); cellStyleFormats1.Append(cellFormat3); cellStyleFormats1.Append(cellFormat4); var cellFormats1 = new CellFormats {Count = 5U}; var cellFormat5 = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U }; var cellFormat6 = new CellFormat { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true }; var cellFormat7 = new CellFormat { NumberFormatId = 0U, FontId = 2U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true, ApplyBorder = true }; var cellFormat8 = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyAlignment = true }; var cellFormat9 = new CellFormat { NumberFormatId = 0U, FontId = 3U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true, ApplyAlignment = true }; var alignment1 = new Alignment {Horizontal = HorizontalAlignmentValues.Center}; cellFormat9.Append(alignment1); cellFormats1.Append(cellFormat5); cellFormats1.Append(cellFormat6); cellFormats1.Append(cellFormat7); cellFormats1.Append(cellFormat8); cellFormats1.Append(cellFormat9); var cellStyles1 = new CellStyles {Count = 4U}; var cellStyle1 = new CellStyle {Name = "Custom", FormatId = 3U}; var cellStyle2 = new CellStyle {Name = "Нейтральный", FormatId = 2U, BuiltinId = 28U, CustomBuiltin = true}; var cellStyle3 = new CellStyle {Name = "Обычный", FormatId = 0U, BuiltinId = 0U}; var cellStyle4 = new CellStyle {Name = "Плохой", FormatId = 1U, BuiltinId = 27U, CustomBuiltin = true}; cellStyles1.Append(cellStyle1); cellStyles1.Append(cellStyle2); cellStyles1.Append(cellStyle3); cellStyles1.Append(cellStyle4); var differentialFormats1 = new DifferentialFormats {Count = 0U}; var tableStyles1 = new TableStyles { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; var stylesheetExtensionList1 = new StylesheetExtensionList(); var stylesheetExtension1 = new StylesheetExtension {Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"}; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); var slicerStyles1 = new X14.SlicerStyles {DefaultSlicerStyle = "SlicerStyleLight1"}; stylesheetExtension1.Append(slicerStyles1); stylesheetExtensionList1.Append(stylesheetExtension1); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); stylesheet1.Append(cellStyles1); stylesheet1.Append(differentialFormats1); stylesheet1.Append(tableStyles1); stylesheet1.Append(stylesheetExtensionList1); return stylesheet1; }
public Stylesheet EnsureStylesheet() { WorkbookPart part = this._wpart; if (part.WorkbookStylesPart == null) { part.AddNewPart <WorkbookStylesPart>(); Stylesheet stylesheet = new Stylesheet(); part.WorkbookStylesPart.Stylesheet = stylesheet; Font font2 = new Font(); FontSize size = new FontSize { Val = 11.0 }; font2.FontSize = size; Color color = new Color { Theme = 1 }; font2.Color = color; FontName name = new FontName { Val = "Calibri" }; font2.FontName = name; FontFamilyNumbering numbering = new FontFamilyNumbering { Val = 2 }; font2.FontFamilyNumbering = numbering; FontScheme scheme = new FontScheme { Val = (FontSchemeValues)2 }; font2.FontScheme = scheme; Font font = font2; Fill fill3 = new Fill(); PatternFill fill4 = new PatternFill { PatternType = (PatternValues)0 }; fill3.PatternFill = fill4; Fill fill = fill3; Fill fill5 = new Fill(); PatternFill fill6 = new PatternFill { PatternType = (PatternValues)0x11 }; fill5.PatternFill = fill6; Fill fill2 = fill5; Border border = new Border { LeftBorder = new LeftBorder(), RightBorder = new RightBorder(), TopBorder = new TopBorder(), BottomBorder = new BottomBorder(), DiagonalBorder = new DiagonalBorder() }; CellFormat format = new CellFormat { NumberFormatId = 0, BorderId = 0, FontId = 0, FillId = 0 }; CellFormat format2 = new CellFormat { NumberFormatId = 0, FontId = 0, BorderId = 0, FillId = 0, FormatId = 0 }; CellStyle style = new CellStyle { Name = "Normal", BuiltinId = 0, FormatId = 0 }; Fonts fonts = new Fonts { Count = 1 }; stylesheet.Fonts = fonts; stylesheet.Fonts.Append(new OpenXmlElement[] { font }); Fills fills = new Fills { Count = 2 }; stylesheet.Fills = fills; stylesheet.Fills.Append(new OpenXmlElement[] { fill }); stylesheet.Fills.Append(new OpenXmlElement[] { fill2 }); Borders borders = new Borders { Count = 1 }; stylesheet.Borders = borders; stylesheet.Borders.Append(new OpenXmlElement[] { border }); CellStyleFormats formats = new CellStyleFormats { Count = 1 }; stylesheet.CellStyleFormats = formats; stylesheet.CellStyleFormats.Append(new OpenXmlElement[] { format }); CellFormats formats2 = new CellFormats { Count = 1 }; stylesheet.CellFormats = formats2; stylesheet.CellFormats.Append(new OpenXmlElement[] { format2 }); CellStyles styles = new CellStyles { Count = 1 }; stylesheet.CellStyles = styles; stylesheet.CellStyles.Append(new OpenXmlElement[] { style }); stylesheet.DifferentialFormats = new DifferentialFormats(); TableStyles styles2 = new TableStyles { Count = 0 }; stylesheet.TableStyles = styles2; } return(part.WorkbookStylesPart.Stylesheet); }
private static Stylesheet CreateStylesheet() { Stylesheet stylesheet1 = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); Fonts fonts1 = new Fonts() { Count = (UInt32Value)1U, KnownFonts = true }; Font font1 = new Font(); FontSize fontSize1 = new FontSize() { Val = 11D }; Color color1 = new Color() { Theme = (UInt32Value)1U }; FontName fontName1 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); fonts1.Append(font1); Fills fills1 = new Fills() { Count = (UInt32Value)5U }; // FillId = 0 Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None }; fill1.Append(patternFill1); // FillId = 1 Fill fill2 = new Fill(); PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Gray125 }; fill2.Append(patternFill2); // FillId = 2,RED Fill fill3 = new Fill(); PatternFill patternFill3 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor1 = new ForegroundColor() { Rgb = "FFFF0000" }; BackgroundColor backgroundColor1 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill3.Append(foregroundColor1); patternFill3.Append(backgroundColor1); fill3.Append(patternFill3); // FillId = 3,BLUE Fill fill4 = new Fill(); PatternFill patternFill4 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor2 = new ForegroundColor() { Rgb = "FF0070C0" }; BackgroundColor backgroundColor2 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill4.Append(foregroundColor2); patternFill4.Append(backgroundColor2); fill4.Append(patternFill4); // FillId = 4,YELLO Fill fill5 = new Fill(); PatternFill patternFill5 = new PatternFill() { PatternType = PatternValues.Solid }; ForegroundColor foregroundColor3 = new ForegroundColor() { Rgb = "FFFFFF00" }; BackgroundColor backgroundColor3 = new BackgroundColor() { Indexed = (UInt32Value)64U }; patternFill5.Append(foregroundColor3); patternFill5.Append(backgroundColor3); fill5.Append(patternFill5); fills1.Append(fill1); fills1.Append(fill2); fills1.Append(fill3); fills1.Append(fill4); fills1.Append(fill5); Borders borders1 = new Borders() { Count = (UInt32Value)1U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); borders1.Append(border1); CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = (UInt32Value)1U }; CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormats1.Append(cellFormat1); CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)4U }; CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true }; CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true }; CellFormat cellFormat5 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)4U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true }; cellFormats1.Append(cellFormat2); cellFormats1.Append(cellFormat3); cellFormats1.Append(cellFormat4); cellFormats1.Append(cellFormat5); CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle1 = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyles1.Append(cellStyle1); DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = (UInt32Value)0U }; TableStyles tableStyles1 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleMedium9" }; StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList(); StylesheetExtension stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); stylesheetExtensionList1.Append(stylesheetExtension1); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); stylesheet1.Append(cellStyles1); stylesheet1.Append(differentialFormats1); stylesheet1.Append(tableStyles1); stylesheet1.Append(stylesheetExtensionList1); return(stylesheet1); }
private static void GenerateWorkbookStylesPartContent(WorkbookStylesPart workbookStylesPart1) { Stylesheet stylesheet1 = new Stylesheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); Fonts fonts1 = new Fonts() { Count = (UInt32Value)2U, KnownFonts = true }; Font font1 = new Font(); FontSize fontSize1 = new FontSize() { Val = 11D }; Color color1 = new Color() { Theme = (UInt32Value)1U }; FontName fontName1 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); Font font2 = new Font(); Bold bold1 = new Bold(); FontSize fontSize2 = new FontSize() { Val = 11D }; Color color2 = new Color() { Theme = (UInt32Value)1U }; FontName fontName2 = new FontName() { Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering() { Val = 2 }; FontScheme fontScheme2 = new FontScheme() { Val = FontSchemeValues.Minor }; font2.Append(bold1); font2.Append(fontSize2); font2.Append(color2); font2.Append(fontName2); font2.Append(fontFamilyNumbering2); font2.Append(fontScheme2); fonts1.Append(font1); fonts1.Append(font2); Fills fills1 = new Fills() { Count = (UInt32Value)2U }; Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None }; fill1.Append(patternFill1); Fill fill2 = new Fill(); PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Gray125 }; fill2.Append(patternFill2); fills1.Append(fill1); fills1.Append(fill2); Borders borders1 = new Borders() { Count = (UInt32Value)2U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); Border border2 = new Border(); LeftBorder leftBorder2 = new LeftBorder() { Style = BorderStyleValues.Thin }; Color color3 = new Color() { Indexed = (UInt32Value)64U }; leftBorder2.Append(color3); RightBorder rightBorder2 = new RightBorder() { Style = BorderStyleValues.Thin }; Color color4 = new Color() { Indexed = (UInt32Value)64U }; rightBorder2.Append(color4); TopBorder topBorder2 = new TopBorder() { Style = BorderStyleValues.Thin }; Color color5 = new Color() { Indexed = (UInt32Value)64U }; topBorder2.Append(color5); BottomBorder bottomBorder2 = new BottomBorder() { Style = BorderStyleValues.Thin }; Color color6 = new Color() { Indexed = (UInt32Value)64U }; bottomBorder2.Append(color6); DiagonalBorder diagonalBorder2 = new DiagonalBorder(); border2.Append(leftBorder2); border2.Append(rightBorder2); border2.Append(topBorder2); border2.Append(bottomBorder2); border2.Append(diagonalBorder2); borders1.Append(border1); borders1.Append(border2); CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = (UInt32Value)1U }; CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormats1.Append(cellFormat1); CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)3U }; CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyBorder = true }; CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyBorder = true }; cellFormats1.Append(cellFormat2); cellFormats1.Append(cellFormat3); cellFormats1.Append(cellFormat4); CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)1U }; CellStyle cellStyle1 = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyles1.Append(cellStyle1); DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = (UInt32Value)0U }; TableStyles tableStyles1 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList(); StylesheetExtension stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); X14.SlicerStyles slicerStyles1 = new X14.SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" }; stylesheetExtension1.Append(slicerStyles1); StylesheetExtension stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" }; stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); X15.TimelineStyles timelineStyles1 = new X15.TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" }; stylesheetExtension2.Append(timelineStyles1); stylesheetExtensionList1.Append(stylesheetExtension1); stylesheetExtensionList1.Append(stylesheetExtension2); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); stylesheet1.Append(cellStyles1); stylesheet1.Append(differentialFormats1); stylesheet1.Append(tableStyles1); stylesheet1.Append(stylesheetExtensionList1); workbookStylesPart1.Stylesheet = stylesheet1; }
public void SetScheme(FontScheme scheme) { (this._ctFont.sizeOfSchemeArray() == 0 ? this._ctFont.AddNewScheme() : this._ctFont.GetSchemeArray(0)).val = (ST_FontScheme)scheme.Value; }
public static void AddStylesToWorkbookPart(WorkbookPart part) { var workbookStylesPart = part.AddNewPart <WorkbookStylesPart>("WorkbookStyles"); var stylesheet1 = new Stylesheet { MCAttributes = new MarkupCompatibilityAttributes { Ignorable = "x14ac" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); var fonts1 = new Fonts { Count = 1U, KnownFonts = true }; var font1 = new Font(); var fontSize1 = new FontSize { Val = 11D }; var color1 = new Color { Theme = 1U }; var fontName1 = new FontName { Val = "Calibri" }; var fontFamilyNumbering1 = new FontFamilyNumbering { Val = 2 }; var fontScheme1 = new FontScheme { Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); fonts1.Append(font1); var fills1 = new Fills { Count = 2U }; var fill1 = new Fill(); var patternFill1 = new PatternFill { PatternType = PatternValues.None }; fill1.Append(patternFill1); var fill2 = new Fill(); var patternFill2 = new PatternFill { PatternType = PatternValues.Gray125 }; fill2.Append(patternFill2); fills1.Append(fill1); fills1.Append(fill2); var borders1 = new Borders { Count = 1U }; var border1 = new Border(); var leftBorder1 = new LeftBorder(); var rightBorder1 = new RightBorder(); var topBorder1 = new TopBorder(); var bottomBorder1 = new BottomBorder(); var diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); borders1.Append(border1); var cellStyleFormats1 = new CellStyleFormats { Count = 1U }; var cellStyleFormat = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U }; cellStyleFormats1.Append(cellStyleFormat); var cellFormats = new CellFormats { Count = 2U }; // index 0 (default) => unlocked var cellFormat0 = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyProtection = true }.AppendItem(new Protection { Locked = false }); // index 1 => locked var cellFormat1 = new CellFormat { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U }; cellFormats.Append(cellFormat0); cellFormats.Append(cellFormat1); var cellStyles1 = new CellStyles { Count = 1U }; var cellStyle1 = new CellStyle { Name = "Normal", FormatId = 0U, BuiltinId = 0U }; cellStyles1.Append(cellStyle1); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats); stylesheet1.Append(cellStyles1); workbookStylesPart.Stylesheet = stylesheet1; }
// Generates content of workbookStyles. private void GenerateWorkbookStylesContent(WorkbookStylesPart workbookStyles) { Stylesheet stylesheet1 = new Stylesheet(){ MCAttributes = new MarkupCompatibilityAttributes(){ Ignorable = "x14ac" } }; stylesheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); stylesheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); NumberingFormats numberingFormats1 = new NumberingFormats(){ Count = (UInt32Value)1U }; NumberingFormat numberingFormat1 = new NumberingFormat(){ NumberFormatId = (UInt32Value)43U, FormatCode = "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)" }; numberingFormats1.Append(numberingFormat1); Fonts fonts1 = new Fonts(){ Count = (UInt32Value)4U, KnownFonts = true }; Font font1 = new Font(); FontSize fontSize1 = new FontSize(){ Val = 11D }; Color color1 = new Color(){ Theme = (UInt32Value)1U }; FontName fontName1 = new FontName(){ Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering(){ Val = 2 }; FontScheme fontScheme1 = new FontScheme(){ Val = FontSchemeValues.Minor }; font1.Append(fontSize1); font1.Append(color1); font1.Append(fontName1); font1.Append(fontFamilyNumbering1); font1.Append(fontScheme1); Font font2 = new Font(); Bold bold1 = new Bold(); FontSize fontSize2 = new FontSize(){ Val = 11D }; Color color2 = new Color(){ Theme = (UInt32Value)1U }; FontName fontName2 = new FontName(){ Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering2 = new FontFamilyNumbering(){ Val = 2 }; FontScheme fontScheme2 = new FontScheme(){ Val = FontSchemeValues.Minor }; font2.Append(bold1); font2.Append(fontSize2); font2.Append(color2); font2.Append(fontName2); font2.Append(fontFamilyNumbering2); font2.Append(fontScheme2); Font font3 = new Font(); Bold bold2 = new Bold(); Italic italic1 = new Italic(); FontSize fontSize3 = new FontSize(){ Val = 11D }; Color color3 = new Color(){ Rgb = "FFFF0000" }; FontName fontName3 = new FontName(){ Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering3 = new FontFamilyNumbering(){ Val = 2 }; FontScheme fontScheme3 = new FontScheme(){ Val = FontSchemeValues.Minor }; font3.Append(bold2); font3.Append(italic1); font3.Append(fontSize3); font3.Append(color3); font3.Append(fontName3); font3.Append(fontFamilyNumbering3); font3.Append(fontScheme3); Font font4 = new Font(); Italic italic2 = new Italic(); FontSize fontSize4 = new FontSize(){ Val = 11D }; Color color4 = new Color(){ Rgb = "FFFF0000" }; FontName fontName4 = new FontName(){ Val = "Calibri" }; FontFamilyNumbering fontFamilyNumbering4 = new FontFamilyNumbering(){ Val = 2 }; FontScheme fontScheme4 = new FontScheme(){ Val = FontSchemeValues.Minor }; font4.Append(italic2); font4.Append(fontSize4); font4.Append(color4); font4.Append(fontName4); font4.Append(fontFamilyNumbering4); font4.Append(fontScheme4); fonts1.Append(font1); fonts1.Append(font2); fonts1.Append(font3); fonts1.Append(font4); Fills fills1 = new Fills(){ Count = (UInt32Value)4U }; Fill fill1 = new Fill(); PatternFill patternFill1 = new PatternFill(){ PatternType = PatternValues.None }; fill1.Append(patternFill1); Fill fill2 = new Fill(); PatternFill patternFill2 = new PatternFill(){ PatternType = PatternValues.Gray125 }; fill2.Append(patternFill2); Fill fill3 = new Fill(); PatternFill patternFill3 = new PatternFill(){ PatternType = PatternValues.Solid }; ForegroundColor foregroundColor1 = new ForegroundColor(){ Theme = (UInt32Value)0U, Tint = -4.9989318521683403E-2D }; BackgroundColor backgroundColor1 = new BackgroundColor(){ Indexed = (UInt32Value)64U }; patternFill3.Append(foregroundColor1); patternFill3.Append(backgroundColor1); fill3.Append(patternFill3); Fill fill4 = new Fill(); PatternFill patternFill4 = new PatternFill(){ PatternType = PatternValues.Solid }; ForegroundColor foregroundColor2 = new ForegroundColor(){ Rgb = "FFFFFFCC" }; BackgroundColor backgroundColor2 = new BackgroundColor(){ Indexed = (UInt32Value)64U }; patternFill4.Append(foregroundColor2); patternFill4.Append(backgroundColor2); fill4.Append(patternFill4); fills1.Append(fill1); fills1.Append(fill2); fills1.Append(fill3); fills1.Append(fill4); Borders borders1 = new Borders(){ Count = (UInt32Value)2U }; Border border1 = new Border(); LeftBorder leftBorder1 = new LeftBorder(); RightBorder rightBorder1 = new RightBorder(); TopBorder topBorder1 = new TopBorder(); BottomBorder bottomBorder1 = new BottomBorder(); DiagonalBorder diagonalBorder1 = new DiagonalBorder(); border1.Append(leftBorder1); border1.Append(rightBorder1); border1.Append(topBorder1); border1.Append(bottomBorder1); border1.Append(diagonalBorder1); Border border2 = new Border(); LeftBorder leftBorder2 = new LeftBorder(); RightBorder rightBorder2 = new RightBorder(); TopBorder topBorder2 = new TopBorder(){ Style = BorderStyleValues.Thin }; Color color5 = new Color(){ Indexed = (UInt32Value)64U }; topBorder2.Append(color5); BottomBorder bottomBorder2 = new BottomBorder(); DiagonalBorder diagonalBorder2 = new DiagonalBorder(); border2.Append(leftBorder2); border2.Append(rightBorder2); border2.Append(topBorder2); border2.Append(bottomBorder2); border2.Append(diagonalBorder2); borders1.Append(border1); borders1.Append(border2); CellStyleFormats cellStyleFormats1 = new CellStyleFormats(){ Count = (UInt32Value)1U }; CellFormat cellFormat1 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U }; cellStyleFormats1.Append(cellFormat1); CellFormats cellFormats1 = new CellFormats(){ Count = (UInt32Value)16U }; CellFormat cellFormat2 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U }; CellFormat cellFormat3 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment1 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat3.Append(alignment1); CellFormat cellFormat4 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true }; CellFormat cellFormat5 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment2 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Left }; cellFormat5.Append(alignment2); CellFormat cellFormat6 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment3 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat6.Append(alignment3); CellFormat cellFormat7 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment4 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat7.Append(alignment4); CellFormat cellFormat8 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment5 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Right }; cellFormat8.Append(alignment5); CellFormat cellFormat9 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true, ApplyAlignment = true }; Alignment alignment6 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Left }; cellFormat9.Append(alignment6); CellFormat cellFormat10 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true, ApplyAlignment = true }; Alignment alignment7 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat10.Append(alignment7); CellFormat cellFormat11 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)3U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment8 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat11.Append(alignment8); CellFormat cellFormat12 = new CellFormat(){ NumberFormatId = (UInt32Value)43U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFont = true, ApplyFill = true }; CellFormat cellFormat13 = new CellFormat(){ NumberFormatId = (UInt32Value)9U, FontId = (UInt32Value)0U, FillId = (UInt32Value)3U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFill = true, ApplyAlignment = true }; Alignment alignment9 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Left }; cellFormat13.Append(alignment9); CellFormat cellFormat14 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyFill = true, ApplyAlignment = true }; Alignment alignment10 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat14.Append(alignment10); CellFormat cellFormat15 = new CellFormat(){ NumberFormatId = (UInt32Value)37U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFont = true, ApplyFill = true, ApplyBorder = true, ApplyAlignment = true }; Alignment alignment11 = new Alignment(){ Horizontal = HorizontalAlignmentValues.Center }; cellFormat15.Append(alignment11); CellFormat cellFormat16 = new CellFormat(){ NumberFormatId = (UInt32Value)43U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true, ApplyFont = true, ApplyFill = true, ApplyBorder = true }; CellFormat cellFormat17 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)2U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyBorder = true }; cellFormats1.Append(cellFormat2); cellFormats1.Append(cellFormat3); cellFormats1.Append(cellFormat4); cellFormats1.Append(cellFormat5); cellFormats1.Append(cellFormat6); cellFormats1.Append(cellFormat7); cellFormats1.Append(cellFormat8); cellFormats1.Append(cellFormat9); cellFormats1.Append(cellFormat10); cellFormats1.Append(cellFormat11); cellFormats1.Append(cellFormat12); cellFormats1.Append(cellFormat13); cellFormats1.Append(cellFormat14); cellFormats1.Append(cellFormat15); cellFormats1.Append(cellFormat16); cellFormats1.Append(cellFormat17); CellStyles cellStyles1 = new CellStyles(){ Count = (UInt32Value)1U }; CellStyle cellStyle1 = new CellStyle(){ Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U }; cellStyles1.Append(cellStyle1); DifferentialFormats differentialFormats1 = new DifferentialFormats(){ Count = (UInt32Value)0U }; TableStyles tableStyles1 = new TableStyles(){ Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" }; StylesheetExtensionList stylesheetExtensionList1 = new StylesheetExtensionList(); StylesheetExtension stylesheetExtension1 = new StylesheetExtension(){ Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" }; stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles slicerStyles1 = new DocumentFormat.OpenXml.Office2010.Excel.SlicerStyles(){ DefaultSlicerStyle = "SlicerStyleLight1" }; stylesheetExtension1.Append(slicerStyles1); //StylesheetExtension stylesheetExtension2 = new StylesheetExtension(){ Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" }; //stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"); //X15.TimelineStyles timelineStyles1 = new X15.TimelineStyles(){ DefaultTimelineStyle = "TimeSlicerStyleLight1" }; //stylesheetExtension2.Append(timelineStyles1); stylesheetExtensionList1.Append(stylesheetExtension1); //stylesheetExtensionList1.Append(stylesheetExtension2); stylesheet1.Append(numberingFormats1); stylesheet1.Append(fonts1); stylesheet1.Append(fills1); stylesheet1.Append(borders1); stylesheet1.Append(cellStyleFormats1); stylesheet1.Append(cellFormats1); stylesheet1.Append(cellStyles1); stylesheet1.Append(differentialFormats1); stylesheet1.Append(tableStyles1); stylesheet1.Append(stylesheetExtensionList1); workbookStyles.Stylesheet = stylesheet1; }