Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对于查询:
OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from[" + sheetName + "$] where [BARKOD] is not null", Connection);
我可以获取特定列的数据,例如列 1(header=ID) 和 3(header=NAME) 而不是整个表 (*)?
您可以先选择列名,例如:
DataTable schemaColTable = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, null); String firstColumnName = schemaColTable.Select(null, "TABLE_NAME,ORDINAL_POSITION", DataViewRowState.CurrentRows)[0]["COLUMN_NAME"].ToString();
然后,您将这些列名用于您的查询。