using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NPOI.HSSF.UserModel;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.HSSF.Util;
using NPOI.HSSF.UserModel.Contrib;
using System.IO;
namespace ConsoleApplication7
{
class Class11
{
static void Main(string[] args)
{
HSSFWorkbook book = new HSSFWorkbook();
Sheet sheet = book.CreateSheet("bb");
FileStream fs = new FileStream(@"C:\Users\jim\Desktop\aaa\aa.xls", FileMode.OpenOrCreate);
for (int i = 0; i < 10; i++)
{
Row row = sheet.CreateRow(i);
for (int j = 0; j < 10; j++)
{
Cell cell = row.CreateCell(j);
cell.SetCellValue(10);
CellStyle cs = book.CreateCellStyle();
cs.BorderLeft = CellBorderType.THIN;
cs.BorderBottom = CellBorderType.THIN;
cs.BorderRight = CellBorderType.THIN;
cs.BorderTop = CellBorderType.THIN;
cs.FillBackgroundColor = HSSFColor.RED.index;
cs.FillForegroundColor = HSSFColor.RED.index;
cell.CellStyle = cs;
}
}
book.Write(fs);
fs.Close();
}
}
}