C#怎么在一个已经存在的EXCEL里写入数据

2024-11-08 23:48:42
推荐回答(4个)
回答1:

  1. 添加excel类库引用

  2. //加载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();

回答2:

Excel 2016 怎么使用通配符查找数据

回答3:

进入编辑栏中编辑

回答4:

c# 读写数据实例提供