Esempio n. 1
0
        private void AddCellFormats(Stylesheet stylesheet)
        {
            var cellWriters      = BaseExcelCellWriter.GetAllCellWriters().ToList();
            var cellWritersCount = cellWriters.Count;
            var cellFormatsCount = cellWritersCount + 1;
            var cellFormats      = new CellFormats()
            {
                Count = (UInt32)cellFormatsCount
            };

            cellFormats.Append(new CellFormat());
            for (int index = 1; index <= cellWritersCount; index++)
            {
                var excelCellFormat          = (ExcelCellFormat)index;
                var excelCellFormatAttribute = BaseExcelCellWriter.GetExcelFormatMemberAttribute(excelCellFormat);
                var numberFormat             = excelCellFormatAttribute.NumberFormat;
                var applyNumberFormat        = excelCellFormatAttribute.ApplyNumberFormat;
                var templateCellFormat       = excelCellFormat == ExcelCellFormat.Header
                                        ? _tplHeaderCellFormat
                                        : _tplValueCellFormat;
                var cellFormat = GetCellFormat(templateCellFormat, excelCellFormatAttribute);
                cellFormats.Append(cellFormat);
            }
            stylesheet.Append(cellFormats);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds custom formats to <paramref name="stylesheet"/>.
        /// </summary>
        /// <param name="stylesheet">Constructing stylesheet.</param>
        protected virtual void AddCustomFormats(Stylesheet stylesheet)
        {
            stylesheet.NumberingFormats = new NumberingFormats {
                Count = 0
            };
            var dateTimeNumberFormat = BaseExcelCellWriter.GetExcelFormatMemberAttribute(ExcelCellFormat.DateTime).NumberFormat;

            AppendFormat(stylesheet, dateTimeNumberFormat, GetDateTimeFormatCode());
            var dateNumberFormat = BaseExcelCellWriter.GetExcelFormatMemberAttribute(ExcelCellFormat.Date).NumberFormat;

            AppendFormat(stylesheet, dateNumberFormat, StringValue.FromString(DateTimeFormat.ShortDatePattern));
        }