Cant create Excel file using OLEDB C#

2019-03-02 16:23发布

 string TempFileLocation="Filelocation";
 string tempfilename ="FileName";
 string TabName ="TabName";
 string xConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source="  +TempFileLocation+     tempfilename +".xls;Extended Properties='Excel 8.0;HDR=YES'";
 var conn = new OleDbConnection(xConnStr);
 string ColumnName ="[columename] varchar(255)"
 conn.Open();
 var cmd = new OleDbCommand("CREATE TABLE [" + TabName + "] (" + ColumnName + ")", conn);
 cmd.ExecuteNonQuery();
 conn.Close();

I using above code to create the table but it did not allow me to create ColumnName with more than 64 characters. Please give me soluition for this problem.

标签: c# excel oledb
1条回答
干净又极端
2楼-- · 2019-03-02 16:39

The column name cannot be over 64 characters.

According to MSDN:

Maximum column name length:
Column names over 64 characters will produce an error.

查看更多
登录 后发表回答