在C#中将Excel信息导入DataTable时的列限制

时间:2015-07-22 19:41:25

标签: c# windows winforms visual-studio import-from-excel

我从excel表导入数据时遇到问题,我有32列,但是当我填写DataTable时,它只带了19列。是否有列的限制

我的代码是:

using (OleDbConnection con = new OleDbConnection(conStr))
            {
                using (OleDbCommand cmd = new OleDbCommand())
                {
                    using (OleDbDataAdapter oda = new OleDbDataAdapter())
                    {
                        DataTable dt = new DataTable();
                        cmd.CommandText = "SELECT * From [" + sheetName + "]";
                        cmd.Connection = con;
                        con.Open();
                        oda.SelectCommand = cmd;
                        oda.Fill(dt);
                        con.Close();

                        //lleno el DataGridView.
                        grdExcel.DataSource = dt;
                    }
                }
            }

0 个答案:

没有答案