我正在使用ASP.NET开发一个网络应用程序,并使用MySQL数据库。当我通过此应用程序上传Excel文件(.xlsx)时,没有任何问题。但当文件超过24904条记录时问题就出现了。
此时会出现以下错误:
此表格包含超出此电子表格定义的单元格范围的单元格。
并且仅写入前24904条记录。
我尝试将负载分成多个批次进行加载,但不起作用。
有什么想法吗?
Dim connExcel As New System.Data.OleDb.OleDbConnection(conStr)
Dim cmdExcel As New System.Data.OleDb.OleDbCommand()
Dim dt As New DataTable()
Dim dataset As New DataSet
Dim x As Integer = 2
Dim y As Integer = 20001
Dim range As String = "A" + x.ToString + ":" + "I" + y.ToString
cmdExcel.Connection = connExcel
If erro = 0 Then
Try
For i As Integer = 0 To 50
connExcel.Open()
dataset.Reset()
dataset.Clear()
Dim oda As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [Sheet1$" & range.ToString & "]", connExcel)
oda.TableMappings.Add("Table", "ExcelTest")
oda.Fill(dataset)
connExcel.Close()
If dataset.Tables(0).Rows.Count > 0 Then
SendToDB(dataset)
Else
i = 50
End If
x = x + 20000
y = y + 20000
range = "A" + x.ToString + ":" + "I" + y.ToString
Next
Label7.Visible = True
Label7.Text = "The information has been written successfully from 0 to " + y.ToString
Catch ex As Exception
Label9.Visible = True
Label9.Text = "Database Error 2:" + ex.Message
connExcel.Close()
End Try
End If