NPOI 添加行

时间:2022-08-01 17:49:14
                IRow sourceRow = sheet1.GetRow();

                for (int i = ; i < dt.Rows.Count-; i++)
{ IRow row = sheet1.CreateRow( + i);
row.Height = sourceRow.Height;
for (int m = sourceRow.FirstCellNum; m < sourceRow.LastCellNum; m++)
{
ICell cell = row.CreateCell(m);
// cell.SetCellValue("0");
ICellStyle cellStyle = sourceRow.Cells[m].CellStyle;
cellStyle.Alignment = HorizontalAlignment.CENTER;
cell.CellStyle = cellStyle; cell.SetCellType(sourceRow.Cells[m].CellType);
} }