示例#1
0
        static void InitStyles(SpreadsheetDocument doc)
        {
            superscript = new RunProperties(
                new VerticalTextAlignment()
            {
                Val = VerticalAlignmentRunValues.Superscript
            }
                , new FontSize()
            {
                Val = 11.0
            }
                );

            var stylesheet = doc.GetStylesheet();

            styleRed = stylesheet.MakeCellStyle().WithFill("FF9090").Build();

            var titleFont = new Font()
            {
                FontSize = new FontSize()
                {
                    Val = 18U
                },
                Bold = new Bold()
                {
                    Val = true
                }
            };

            styleGreen = stylesheet.MakeCellStyle().WithFill("90FF90").WithFont(titleFont).Build();

            styleBlue = stylesheet.MakeCellStyle().WithFill("9090FF").Build();
        }
示例#2
0
        /// <summary>
        /// Удаленин элементов TimelineStyles
        /// </summary>
        /// <param name="doc"></param>
        public static void RemoveOffice2013TimelineStyles(SpreadsheetDocument doc)
        {
            var stylesheet     = doc.GetStylesheet();
            var timelineStyles = stylesheet.Descendants <excel2013.TimelineStyles>();

            ElementsRemove.RemoveElements(timelineStyles, deleteSectionIfEmpty: true);
        }
示例#3
0
 public ExcelHelper(string fileName, bool editable = true, int header = 1)
 {
     if (string.IsNullOrEmpty(fileName))
     {
         throw new Exception("Check if current filename is empty!");
     }
     if (!File.Exists(fileName))
     {
         throw new Exception("Please make sure current file exists!");
     }
     document              = SpreadsheetDocument.Open(fileName, editable);
     worksheet             = document.GetWorksheet(0);
     sheetData             = worksheet.GetSheetData();
     styleSheet            = document.GetStylesheet();
     this.Header           = header;
     this.cellFormatOption = CellFormatOption.OverWrite;
 }