使用OLEDB导入Excel不引入折叠的组

我创build了一个程序来挖掘和从大约75个电子表格导入数据到一个oracle表。 我可以连接,遍历表单,抓取单元格和行看似很好。 问题是,如果excel工作表保存在分组行中,则会跳过这些行。 如果有一个扩展的财产或注册设置让我有可能扩大进入的团体,我不能find任何地方? 不知道如何绕过一个折叠组(不合并单元格,我可以处理没有问题)。

码位:

//Starting where I iterate through a particular sheet var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=\"Excel 12.0;HDR=NO;IMEX=1;ReadOnly=0\"", fileName); OleDbConnection objConn = new OleDbConnection(connectionString); try { objConn.Open(); System.Data.DataTable dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); if (dt != null) { foreach (DataRow row in dt.Rows) { var adapter = new OleDbDataAdapter("SELECT F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12 FROM [" + row["TABLE_NAME"].ToString() + "]", connectionString); var ds = new DataSet(); try { adapter.Fill(ds, "anyname"); } catch { break; } DataTable data = ds.Tables[0]; int rownum = 0; // <a bunch of variable declarations> foreach (DataRow row_b in data.Rows) { // start slogging through the rows rownum = rownum++; // <reset some variables> if (rownum == 1) // Catch valid scripts that contain a number { foreach (DataColumn column in data.Columns) { if (column.ToString() == "F1") { // <processing code for this column> } if (column.ToString() == "F2") { // <processing code for this column> } if (column.ToString() == "F3") { // <you get the picture> } } } if (rownum == 3) { // <moving along through the rows...different processing> } // <..rows 4-11..> if (rownum > 12 ) { // <more value assignment> } string allvals = APPLICATION + E_USER + STEP_DESC + VARIATIONS + STATUS + STOPS_TESTING + ISSUE_NUM + ISSUE_COMMENTS + ADDITIONAL_INFO; allvals = allvals.Trim(); //Don't want sheets that come across as Print Area this shouldn't affect the row processing isPrintArea = 0; if (BOOKSHEET.Contains("Print_Area")) { isPrintArea = 1; } Boolean addornot=false; if (cb_forallscripts.Checked == true) { addornot = (STEP_NUM != 0 && allvals != "" && isPrintArea == 0 && SCRIPT_NUM != 0); } else { addornot = (STEP_NUM != 0 && allvals != "" && isPrintArea == 0 && SCRIPT_NUM != 0 && runScripts.Contains(SCRIPT_NUM.ToString())); } if (addornot) { //<connect to our Oracle db, I set up oCmd outside this> OracleCommand oCmd = new OracleCommand(); oCmd.Connection = oConn; oCmd.CommandType = CommandType.Text; oCmd.Parameters.Add("STEP_NUM", STEP_NUM); // <... bunch of parameters ...> oCmd.Parameters.Add("script", SCRIPT); oCmd.CommandText = "<My insert statement> "; oCmd.ExecuteNonQuery(); } } } } } catch ( <error processing>) { } 

Rows.OutlineLevel应该是您正在寻找的VBA属性。 它可以被读取或设置。 看到这个页面的微软相当简洁的描述。 正如它所说的,Range.ClearOutline将清除指定范围的轮廓,如此处所述。