一个excel有三个sheet用nopi如何做..........如果
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
ISheet sheet = hssfworkbook.CreateSheet(str_SheetName);
using (FileStream fs = new FileStream(str_Path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
hssfworkbook.Write(fs);
}
结果是只剩下新建的表
npoi插入(或者说添加新增)一个新的sheet
答案:2 悬赏:30 手机版
解决时间 2021-02-13 00:57
- 提问者网友:蓝莓格格巫
- 2021-02-12 19:55
最佳答案
- 五星知识达人网友:迟山
- 2021-02-12 21:02
string fileName = @"f:\2015光盘内容一览.xls";
HSSFWorkbook workbook;
using(FileStream stream = File.OpenRead(fileName))
workbook = new HSSFWorkbook(stream);
ISheet sheet = workbook.CreateSheet("菜鸟");
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
workbook.Write(fs);
HSSFWorkbook workbook;
using(FileStream stream = File.OpenRead(fileName))
workbook = new HSSFWorkbook(stream);
ISheet sheet = workbook.CreateSheet("菜鸟");
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
workbook.Write(fs);
全部回答
- 1楼网友:英雄的欲望
- 2021-02-12 22:05
string filename = @"f:\2015光盘内容一览.xls";
hssfworkbook workbook;
using (filestream stream = file.openread(filename))
workbook = new hssfworkbook(stream);
isheet sheet = workbook.getsheet("菜鸟"); //获取名称是“菜鸟”的表。
irow row = sheet.createrow(0); //在第一行位置创建一行。
row.createcell(0).setcellvalue("测试"); //在第一列位置创建一列,并赋值“测试”。
using (filestream fs = new filestream(filename, filemode.open, fileaccess.readwrite, fileshare.readwrite))
workbook.write(fs);以上示例,读取xls文件,然后在“菜鸟”表第一行第一列填写文本"测试"并保存更新。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯