C#怎么在一个已经存在的EXCEL里写入数据
答案:3 悬赏:0 手机版
解决时间 2021-03-31 03:14
- 提问者网友:刺鸟
- 2021-03-30 12:40
C#怎么在一个已经存在的EXCEL里写入数据
最佳答案
- 五星知识达人网友:鸽屿
- 2021-03-30 12:46
添加excel类库引用
//加载excel
Application app = new Application();
Workbooks wb = app.Workbooks;
_Workbook _wb = wb.Add("excel路径");
//获取sheet
Sheets sh = _wb.Sheets;
_Worksheet _wsh = (_Worksheet)sh.get_Item(1);
_wsh.Cells[3, 2] = person.Name;//3为excel行,2为excel列
_wsh.SaveAs("填写完成后要保存的路径",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
_wb.Close();
wb.Close();
//加载excel
Application app = new Application();
Workbooks wb = app.Workbooks;
_Workbook _wb = wb.Add("excel路径");
//获取sheet
Sheets sh = _wb.Sheets;
_Worksheet _wsh = (_Worksheet)sh.get_Item(1);
_wsh.Cells[3, 2] = person.Name;//3为excel行,2为excel列
_wsh.SaveAs("填写完成后要保存的路径",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
_wb.Close();
wb.Close();
全部回答
- 1楼网友:低血压的长颈鹿
- 2021-03-30 15:37
c# 读写数据实例提供
- 2楼网友:零点过十分
- 2021-03-30 14:08
进入编辑栏中编辑
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯