private void AppendToXlscell(ReportFile RF) { ISheet sheet1 = RF.hssfworkbook.GetSheet("Sheet1"); int RowCount = sheet1.LastRowNum + 1; HSSFWorkbook hssfworkbook = new HSSFWorkbook(); ICellStyle cellstyle = hssfworkbook.CreateCellStyle(); cellstyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; IRow newRow = sheet1.CreateRow(RowCount); for (int i = 0; i < 13; i++) { ICell cell = newRow.CreateCell(i); cell.SetCellValue((string)RFcolumns.GetType().GetFields()[i].GetValue(RFcolumns)); cell.CellStyle = cellstyle; if (i == 5 | i == 6) { cell.CellStyle.WrapText = true; } } sheet1.ForceFormulaRecalculation = true; RF.WriteToFile(); }
private void AppendToXlscell(ReportFile RF, int index, ReportFileColumns RFC) { ISheet sheet1 = RF.hssfworkbook.GetSheet("Sheet1"); int Rowindex = index; IRow newRow = sheet1.CreateRow(Rowindex); newRow.HeightInPoints = 20; ICellStyle cellstyle = RF.hssfworkbook.CreateCellStyle(); cellstyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; cellstyle.VerticalAlignment = VerticalAlignment.Center; // ICellStyle DatecellStype = RF.hssfworkbook.CreateCellStyle(); // IDataFormat format = RF.hssfworkbook.CreateDataFormat(); for (int i = 0; i < 13; i++) { ICell cell = newRow.CreateCell(i); cell.SetCellValue((string)RFC.GetType().GetFields()[i].GetValue(RFC)); cell.CellStyle = cellstyle; /* if (i == 10) * { * cell.SetCellValue((DateTime)RFC.GetType().GetFields()[i].GetValue(RFC)); * * DatecellStype.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; * DatecellStype.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; * DatecellStype.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; * DatecellStype.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; * DatecellStype.VerticalAlignment = VerticalAlignment.Center; * DatecellStype.DataFormat = format.GetFormat("m/d/yy"); * cell.CellStyle = DatecellStype; * // cell.CellStyle.WrapText = true; * } * else * {*/ } sheet1.ForceFormulaRecalculation = true; }