私はc#が初めてで、次のコードを使用してc#でXLSXファイルを読み込もうとしています:
string Connection = "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=c:\\Temp\\source.xlsx;Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\";";
//code to read the content of format file
OleDbConnection con = new OleDbConnection(Connection);
OleDbCommand command = new OleDbCommand();
DataTable dt = new DataTable();
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Tabelle1$]", con);
myCommand.Fill(dt);
Console.Write(dt.Rows.Count);
出力から正しいカウントが得られましたが、さらに 2 つの質問があります。
1.select whereステートメントを作成するにはどうすればよいですか(行にアクセスする方法)?
select * from [Tabelle1$] where A = '123' (A being an existing Excel row)
間違ったパラメータについて言及しているエラーがスローされます...
2.チュートリアルのリンクまたはデータへのアクセス方法の短いサンプルを提供してくれる人はいますか?