Esempio n. 1
0
        /// <summary>
        /// Adds OpenXml <see cref="CellStyle"/> to document.
        /// </summary>
        /// <param name="documentContext">Source document.</param>
        /// <param name="cellStyle">CellStyle to add.</param>
        /// <param name="name">Name attached to cellStyle.</param>
        /// <returns>The same document context.</returns>
        public static DocumentContext AddCellStyle(this DocumentContext documentContext, CellStyle cellStyle, string name)
        {
            Stylesheet stylesheet = documentContext.GetStylesheet();

            if (stylesheet.CellStyles == null)
            {
                stylesheet.CellStyles = new CellStyles();
            }

            stylesheet.CellStyles.AppendChild(cellStyle.SetStyleSheetName(name));
            stylesheet.CellStyles.Count = (uint)stylesheet.CellStyles.ChildElements.Count;

            return(documentContext);
        }