Exemplo n.º 1
0
        public void SetCellStyle(ICell cell, ICellStyle npoiCellStyle)
        {
            CellStyleWrapper cellStyle = new CellStyleWrapper(npoiCellStyle);
              string cellStyleKey = cellStyle.GetKey();

              if (cellStyles.ContainsKey(cellStyleKey)) {
            // reuse cached styles
            CellStyleWrapper cachedCellStyle = cellStyles[cellStyleKey];
            cell.CellStyle = cachedCellStyle.CellStyle;
              } else {
            // If the style does not exist create a new one
            ICellStyle newCellStyle = xlWorkbook.CreateCellStyle();
            CopyCellStyle(xlWorkbook, npoiCellStyle, newCellStyle);
            Add(new CellStyleWrapper(newCellStyle));
            cell.CellStyle = newCellStyle;
              }
        }
Exemplo n.º 2
0
 private void Add(CellStyleWrapper wrapper)
 {
     string key = wrapper.GetKey();
       Debug.Print("Creating style " + xlWorkbook.NumCellStyles + " " + key);
       cellStyles.Add(key, wrapper);
 }