改为尝试: EPPlus-Create advanced服务器上的Excel电子表格 - 主页 [ ^ ]
要接受挑战,您必须按照以下步骤操作:
To be up to the challenge, you have to follow below steps:
- 使用 OleDbConnection [ ^ ]
- 创建 OleDbCommand [ ^ ]使用 OleDbDataReader [ ^ ]
- 将数据加载到DataTable [ ^ ]
- 与Excel表断开连接
- 使用 SqlConnection [ ^ ]
- 使用SqlBu lkCopy类 [ ^ ]
- 断开与Sql数据库的连接
- Connect to the Excel sheet using OleDbConnection[^]
- Create OleDbCommand[^] to read the data using OleDbDataReader[^]
- Load data into DataTable[^]
- Disconnect with Excel sheet
- Connect to the SQL database using SqlConnection[^]
- Copy data into SQL table using SqlBulkCopy class[^]
- Disconnect with Sql database
这就是全部!试试吧!
注意:不要遍历Excel表格中的行集合!这就是你遇到问题的原因。