我读取了下面这张图片,读取代码在下面,我想实现的是在第四行的管理费后面追加一条数据 ,这个应该怎么写
代码如下
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
op.ShowDialog();
//要操作的excel文件路径
string path = op.FileName.ToString();
//把文件内容导入到工作薄当中,然后关闭文件
FileStream fs = File.OpenRead(path);
HSSFWorkbook workbook = new HSSFWorkbook(fs);
fs.Close();
//编辑工作薄当中内容
ISheet sheet = workbook.GetSheetAt(0);
for (int i = 0; i <= sheet.LastRowNum; i++)//LastRowNum 获取最后一行的行号
{
foreach (ICell cell in sheet.GetRow(i).Cells)
{
}
}
SaveFileDialog opo = new SaveFileDialog();
opo.ShowDialog();
//把编辑过后的工作薄重新保存为excel文件
FileStream fs2 = File.Create(opo.FileName.ToString()+".xls");
workbook.Write(fs2);
fs2.Close();
}
IRow row = sheet.GetRow(i);
ICell celll = row.CreateCell(10);
celll.SetCellValue("我操你大爷的");