C#操作excel增加列如何实现,最好是以下这种方式调用,update是能顺利执行的。
stringstrConn;strConn="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=d:\\abc.xls;Extend...
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= d:\\abc.xls;Extended Properties='Excel 8.0;HDR=Yes;IMEX=0'";
OleDbConnection OleConn = new OleDbConnection(strConn);
OleConn.Open();
// String sql = "update [Sheet1$] set 姓名='abc' where 姓名 like '%朱%'";
//String sql = " Alter Table [Sheet1$] Add a text";
String sql = "alter table [Sheet1$] add abc NVARCHAR (50) NULL";
OleDbCommand mycmd = new OleDbCommand(sql, OleConn);
mycmd.ExecuteNonQuery();
OleConn.Close();
引用 using System.Data.OleDb; 展开
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= d:\\abc.xls;Extended Properties='Excel 8.0;HDR=Yes;IMEX=0'";
OleDbConnection OleConn = new OleDbConnection(strConn);
OleConn.Open();
// String sql = "update [Sheet1$] set 姓名='abc' where 姓名 like '%朱%'";
//String sql = " Alter Table [Sheet1$] Add a text";
String sql = "alter table [Sheet1$] add abc NVARCHAR (50) NULL";
OleDbCommand mycmd = new OleDbCommand(sql, OleConn);
mycmd.ExecuteNonQuery();
OleConn.Close();
引用 using System.Data.OleDb; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询