简体   繁体   English

从迷失方向的excel文件oledb中仅读取一列

[英]reading only a column from disoriented excel file oledb

I have been able to read a normal excel file via oledb, but the task file for my project contains various format issues, like multiple columns merged, a lot of cells under formulae among others, and as a result, the data set has been unable to store the data of excel file. 我已经能够通过oledb读取普通的excel文件,但是我项目的任务文件包含各种格式问题,例如合并了多列,公式下的许多单元格等等,因此数据集无法存储Excel文件的数据。 If I manage to read contents of sheet- 'Input tab', cell numbers AF6-AF-24, my job is done, but the excel file is not getting parsed in excel at all, before i process the column out. 如果我设法读取工作表的“输入选项卡”的内容,单元格编号为AF6-AF-24,我的工作就完成了,但是在处理该列之前,excel文件根本没有在excel中进行解析。 Help please! 请帮助!

 OleDbConnection connExcel = new OleDbConnection("Provider= Microsoft.ACE.OLEDB.12.0;Data Source=P:\\DummyTesterF.xlsx; Extended Properties=\"Excel 12.0;HDR=YES;\"");
             OleDbCommand cmdExcel = new OleDbCommand();
             OleDbDataAdapter Adapter = new OleDbDataAdapter();
             cmdExcel.CommandText = String.Format("SELECT * From ['Input Tab$']");           


             cmdExcel.Connection = connExcel;
             Adapter.SelectCommand = cmdExcel;
             DataTable Table = new DataTable();
             Adapter.Fill(Table);

最好改用Office互操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM