CData ADO.NET Provider for Excel Online 2019J - Online Help

SELECT INTO ステートメント

CData ADO.NET Provider for Excel Online 2019J - Build 19.0.7354

SELECT INTO ステートメントを使って、書式付きデータをファイルにエクスポートできます。

SQL クエリを使ったデータのエクスポート

次のクエリは、comma-separated values(CSV)ファイルフォーマットにデータをエクスポートします。

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;";

using (ExcelOnlineConnection connection = new ExcelOnlineConnection(connectionString)) {
  ExcelOnlineCommand cmd = new ExcelOnlineCommand("SELECT Id, Column1 INTO [csv://Test_xlsx_Sheet1.txt] FROM [Test_xlsx_Sheet1] WHERE Column2 = 'Bob' ", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;" 

Using connection As New ExcelOnlineConnection(connectionString)
  Dim cmd As New ExcelOnlineCommand("SELECT Id, Column1 INTO [csv://Test_xlsx_Sheet1.txt] FROM [Test_xlsx_Sheet1] WHERE Column2 = 'Bob'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using
URI で他のファイルフォーマットを指定できます。以下の例は、tab-separated values(TSV)にエクスポートします。

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;";

using (ExcelOnlineConnection connection = new ExcelOnlineConnection(connectionString)) {
  ExcelOnlineCommand cmd = new ExcelOnlineCommand("SELECT * INTO [Test_xlsx_Sheet1] IN [csv://filename=c:/Test_xlsx_Sheet1.csv;delimiter=tab] FROM [Test_xlsx_Sheet1] WHERE Column2 = 'Bob'", connection);
  int rowsAffected = cmd.ExecuteNonQuery();
} 

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;" 

Using connection As New ExcelOnlineConnection(connectionString)
  Dim cmd As New ExcelOnlineCommand("SELECT * INTO [Test_xlsx_Sheet1] IN [csv://filename=c:/Test_xlsx_Sheet1.csv;delimiter=tab] FROM [Test_xlsx_Sheet1] WHERE Column2 = 'Bob'", connection)
  Dim rowsAffected As Integer = cmd.ExecuteNonQuery()
End Using

 
 
Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 19.0.7354.0