我正在使用 OleDbDataAdapter 读取数据集中 Excel 工作表的内容。Excel 表由 20391 行组成,数据集在我的本地计算机上运行时读取总行数,但在 IIS7.5 服务器上运行代码时,它只读取 FIRST 12463!!
我的连接字符串:
switch (strFileType.Trim())
{
case ".xls":
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strNewPath +
";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
break;
case ".xlsx":
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strNewPath +
";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
break;
}
var query = "SELECT * FROM [" + excelSheets[0] + "]";
//Create the connection object
var conn = new OleDbConnection(connString);
//Open connection
if (conn.State == ConnectionState.Closed) conn.Open();
//Create the command object
var cmd = new OleDbCommand(query, conn);
var da = new OleDbDataAdapter(cmd);
var ds = new DataSet();
da.Fill(ds);
有没有办法将 da.Fill 结果划分为多个数据表?