Exemple #1
0
 public HeadInfo(string name, CellStyleEnum cellStyle, int columnWidth = 30 * 256)
 {
     Name        = name;
     CellStyle   = cellStyle;
     ColumnWidth = columnWidth;
 }
Exemple #2
0
        public static ICellStyle GetCellStyle(XSSFWorkbook wb, CellStyleEnum str)
        {
            var cellStyle = wb.CreateCellStyle();

            switch (str)
            {
            case CellStyleEnum.头:
                // cellStyle.FillPattern = FillPatternType.LEAST_DOTS;
                //cellStyle.SetFont(font12);
                break;

            case CellStyleEnum.月份:
                IDataFormat monthStyle = wb.CreateDataFormat();
                cellStyle.DataFormat = monthStyle.GetFormat("yyyy-MM");
                break;

            case CellStyleEnum.日期:
                IDataFormat datastyle1 = wb.CreateDataFormat();
                cellStyle.DataFormat = datastyle1.GetFormat("yyyy-MM-dd");
                break;

            case CellStyleEnum.时间:
                IDataFormat datastyle = wb.CreateDataFormat();
                cellStyle.DataFormat = datastyle.GetFormat("yyyy-mm-dd");
                break;

            case CellStyleEnum.数字:
                cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00");
                break;

            case CellStyleEnum.钱:
                IDataFormat format = wb.CreateDataFormat();
                cellStyle.DataFormat = format.GetFormat("¥#,##0");
                break;

            case CellStyleEnum.url:
                //fontcolorblue.Underline = 1;
                break;

            case CellStyleEnum.百分比:
                cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00%");
                break;

            case CellStyleEnum.中文大写:
                IDataFormat format1 = wb.CreateDataFormat();
                cellStyle.DataFormat = format1.GetFormat("[DbNum2][$-804]0");
                break;

            case CellStyleEnum.科学计数法:
                cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00E+00");
                break;

            case CellStyleEnum.文本:
                cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("@");
                break;

            case CellStyleEnum.默认:
                break;
            }


            return(cellStyle);
        }