1 //电子表格对象 2 IWorkbook wk = new HSSFWorkbook(); 3 //电子表格Sheet页对象 4 ISheet sheet = wk.CreateSheet("Sheet1"); 5 //电子表格列对象 6 ICellStyle cellStyle = wk.CreateCellStyle(); 7 //样式对象 8 IDataFormat format = wk.CreateDataFormat(); 9 //时间格式化 10 cellStyle.DataFormat = format.GetFormat("0.00"); 11 //下边框 12 cellStyle.BorderBottom = BorderStyle.Thin; 13 //左边框 14 cellStyle.BorderLeft = BorderStyle.Thin; 15 //右边框 16 cellStyle.BorderRight = BorderStyle.Thin; 17 //上边框 18 cellStyle.BorderTop = BorderStyle.Thin; 19 //水平居中 20 cellStyle.Alignment = HorizontalAlignment.Center; 21 //垂直居中 22 cellStyle.VerticalAlignment = VerticalAlignment.Justify;