如何将数据写入到一个已经存在的Excel文件
发布网友
发布时间:2022-04-22 14:14
我来回答
共1个回答
热心网友
时间:2023-10-17 17:51
添加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();