コード例 #1
0
ファイル: ExcelHelper.cs プロジェクト: freedomwork/playground
        public ExcalHelper(String sheetName, String[] rowTitle, int[] rowWidth, int dataRowNum)
        {
            //创建标题行
            workbook = new HSSFWorkbook();
            sheet = (HSSFSheet)workbook.CreateSheet(sheetName);
            this.dataRowNum = dataRowNum;

            HSSFRow rowtitle = (HSSFRow)sheet.CreateRow(0);

            for (int i = 0; i < rowTitle.Length; i++)
            {
                //设置列宽
                sheet.SetColumnWidth(i, rowWidth[i] * 255);
                rowtitle.CreateCell(i).SetCellValue(rowTitle[i]);
            }
        }