コード例 #1
0
        private static void SetCellType(NPOI.SS.UserModel.Cell cell, NPOI.SS.UserModel.CellValue cv)
        {
            NPOI.SS.UserModel.CellType cellType = cv.CellType;
            switch (cellType)
            {
            case NPOI.SS.UserModel.CellType.BOOLEAN:
            case NPOI.SS.UserModel.CellType.ERROR:
            case NPOI.SS.UserModel.CellType.NUMERIC:
            case NPOI.SS.UserModel.CellType.STRING:
                cell.SetCellType(cellType);
                return;

            case NPOI.SS.UserModel.CellType.BLANK:
                // never happens - blanks eventually get translated to zero
                break;

            case NPOI.SS.UserModel.CellType.FORMULA:
                // this will never happen, we have already evaluated the formula
                break;
            }
            throw new InvalidOperationException("Unexpected cell value type (" + cellType + ")");
        }
コード例 #2
0
 /// <summary>
 /// 设置右对齐数字格式
 /// </summary>
 /// <param name="cell"></param>
 /// <returns></returns>
 public static NPOI.SS.UserModel.Cell SetRightDataCell(NPOI.SS.UserModel.Cell cell)
 {
     cell.SetCellType(CellType.NUMERIC);
     cell.CellStyle = GetRightDataCellStyle(cell);
     return(cell);
 }
コード例 #3
0
 /// <summary>
 /// 设置居中对齐加粗字符串格式
 /// </summary>
 /// <param name="cell"></param>
 /// <returns></returns>
 public static NPOI.SS.UserModel.Cell SetCenterBoldStringCell(NPOI.SS.UserModel.Cell cell)
 {
     cell.SetCellType(CellType.STRING);
     cell.CellStyle = GetCenterBoldCellStyle(cell);
     return(cell);
 }