Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public static void RegisterStyle(IExcelStyle moduleStyle, IWorkbook workbook)
 {
     moduleStyle.InitCellStyle(workbook);
     moduleStyle.RegisterCustomStyle(workbook);
 }
Ejemplo n.º 5
0
 public static void RegisterStyle(IExcelStyle moduleStyle, IWorkbook workbook)
 {
     moduleStyle.InitCellStyle(workbook);
     moduleStyle.RegisterCustomStyle(workbook);
 }
Ejemplo n.º 6
0
 public Excel(IExcelStyle excelStyle = null, string filePath = null)
 {
     InternalExcel = new InternalExcel(excelStyle, filePath);
 }