使用 OleDBDataReader 读取 Excel 未检索所有标题列单元格内容
我有一个 Excel 工作表,用于填充数据库中的数据。看起来 OleDBDataReader 在截断其余字符之前实际上只从列标题中读取一定数量的字符。
有办法解决这个问题吗?
我如何检索列标题:
OleDbCommand oleDbCommand = new OleDbCommand("select * from [sheet1$]",
OleDbConnection);
OleDbDataReader reader = oleDbCommand.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(reader);
foreach (DataColumn column in dataTable.Columns)
{
string columnName = column.ColumnName;
}
预期结果:满足学生福利需求的有针对性的计划。例如早餐俱乐部
实际结果:有针对性的计划来满足学生的福利需求。例如 br
我也尝试使用 reader.GetName(i)
方法来检索具有相同结果的信息。
I have an Excel sheet that I am using to populate data in a Database. It seems as though there is only a certain number of characters that the OleDBDataReader actually reads in from a column heading before truncating the rest.
Is there a way around this?
How I am retrieving the column headings:
OleDbCommand oleDbCommand = new OleDbCommand("select * from [sheet1$]",
OleDbConnection);
OleDbDataReader reader = oleDbCommand.ExecuteReader();
DataTable dataTable = new DataTable();
dataTable.Load(reader);
foreach (DataColumn column in dataTable.Columns)
{
string columnName = column.ColumnName;
}
Expected result: Targeted programs to address the welfare needs of students. E.g breakfast clubs
Actual Result: Targeted programs to address the welfare needs of students. E.g br
I have also tried using the reader.GetName(i)
method to retrieve the information with the same result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
64 个字符是 Jet Engine 阅读器的列标题限制。
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/2fb51d81-3d64-445f-806a-519861b561ba/
抱歉,我找不到更好的参考。
64 characters is the column header limit of the Jet Engine reader.
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/2fb51d81-3d64-445f-806a-519861b561ba/
Sorry I cannot find a better reference.