public InternalExcel(IExcelStyle excelStyle = null, string filePath = null) { if (string.IsNullOrWhiteSpace(filePath)) { _workbook = new XSSFWorkbook(); } else { using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { _workbook = WorkbookFactory.Create(fs); } } if (excelStyle != null) ExcelStyleUtil.RegisterStyle(excelStyle, _workbook); }
public InternalExcel(IExcelStyle excelStyle = null, string filePath = null) { if (string.IsNullOrWhiteSpace(filePath)) { _workbook = new XSSFWorkbook(); } else { using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { _workbook = WorkbookFactory.Create(fs); } } if (excelStyle != null) { ExcelStyleUtil.RegisterStyle(excelStyle, _workbook); } }
public void SetExcelStyle(IExcelStyle style) { if (style.IsBuiltInStyle) { ExcelStyle style2 = style as ExcelStyle; for (int i = 0; i < this._workbook.ExcelStyles.Count; i++) { if (this._workbook.ExcelStyles[i].IsBuiltInStyle) { ExcelStyle style3 = this._workbook.ExcelStyles[i] as ExcelStyle; if (style3.BuiltInStyle == style2.BuiltInStyle) { style2.Name = style3.Name; break; } } } } foreach (IExcelStyle style4 in this._workbook.ExcelStyles) { if (style4.Name == style.Name) { if (style4.IsBuiltInStyle) { ExcelStyle style5 = style as ExcelStyle; if (style5 != null) { style4.Format = style5.Format; (style4 as ExcelStyle).Category = style5.Category; (style4 as ExcelStyle).BuiltInStyle = style5.BuiltInStyle; (style4 as ExcelStyle).OutLineLevel = style5.OutLineLevel; (style4 as ExcelStyle).IsCustomBuiltIn = style5.IsCustomBuiltIn; } } else if (style is CustomExcelStyle) { style4.Format = style.Format; } return; } } this._workbook.ExcelStyles.Add(style); }
public static void RegisterStyle(IExcelStyle moduleStyle, IWorkbook workbook) { moduleStyle.InitCellStyle(workbook); moduleStyle.RegisterCustomStyle(workbook); }
public Excel(IExcelStyle excelStyle = null, string filePath = null) { InternalExcel = new InternalExcel(excelStyle, filePath); }