Office 365 のデータをDevExpress Data Grid にデータバインドする。

加藤龍彦
加藤龍彦
デジタルマーケティング
Office 365 用の CData ADO.NET プロバイダーをDevExpress Windows Forms とWeb コントロールとともに使用し、Office 365 をチャートに入力します。

Office 365 用の CData ADO.NET プロバイダーはサードパーティーコントロールで使うことのできる通常のADO.NET データベースアクセスコンポーネントを実装しています。データバインドするための通常のADO.NET プロセスに従うことで、UI コントロールから実データへの双方向アクセスを可能にします。 この記事では、CData を使ってDevExpress Windows Forms とウェブコントロールにデータバインドする方法を説明します。ここでは、最新のデータを表示するチャートにデータバインドします。

Office 365 はOAuth 認証標準を利用しています。OAuth を使って認証するには、アプリケーションを作成してOAuthClientId、OAuthClientSecret、およびCallbackURL 接続プロパティを取得しなければなりません。認証方法については、ヘルプドキュメントの「OAuth 認証の使用」を参照してください。

Windows Forms コントロール

下のコードでは、Office 365 でDevExpress のチャートに追加する方法を説明します。Office365DataAdapter はチャートコントロールのSeries プロパティにバインドします。コントロールのDiagram プロパティはx 軸とy 軸をカラム名として定義します。

using (Office365Connection connection = new Office365Connection(
"OAuthClientId=MyApplicationId;OAuthClientSecret=MyAppKey;OAuthCallbackURL=http://localhost:33333;")) {
  Office365DataAdapter dataAdapter = new Office365DataAdapter(
  "SELECT Name, Size FROM Files ORDER BY Size", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);
  DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series();
  chartControl1.Series.Add(series);
  DataTable table = new DataTable();
  series.ValueDataMembers.AddRange(new string[] { "Size" });
  series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Qualitative;
  series.ArgumentDataMember = "Name";
  series.ValueScaleType = DevExpress.XtraCharts.ScaleType.Numerical;
  chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
  ((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}
The complete code example and the resulting chart.

Web コントロール

下のコードではOffice 365 でDevExpress Web を操作するための設定方法を説明します。Office365DataAdapter はチャートのSeries プロパティにバインドします。Diagram プロパティはx 軸とy 軸をカラム名として定義します。

using DevExpress.XtraCharts;

using (Office365Connection connection = new Office365Connection(
"OAuthClientId=MyApplicationId;OAuthClientSecret=MyAppKey;OAuthCallbackURL=http://localhost:33333;"))
{
  Office365DataAdapter Office365DataAdapter1 = new Office365DataAdapter("SELECT Name, Size FROM Files ORDER BY Size", connection);
  DataTable table = new DataTable();
  Office365DataAdapter1.Fill(table);
  DevExpress.XtraCharts.Series series = new Series("Series1", ViewType.Bar);
  WebChartControl1.Series.Add(series);
  DataTable table = new DataTable();
  series.ValueDataMembers.AddRange(new string[] { "Size" });
  series.ArgumentScaleType = ScaleType.Qualitative;
  series.ArgumentDataMember = "Name";
  series.ValueScaleType = ScaleType.Numerical;
  ((DevExpress.XtraCharts.SideBySideBarSeriesView)series.View).ColorEach = true;
}
An ASP.NET application created with the ADO.NET Provider and the DevExpress Web Forms control.(Salesforce is shown.)

はじめる準備はできましたか?

Office 365 Data Provider の無料トライアルをダウンロードしてお試しください:

 ダウンロード

詳細:

Office 365 Icon Office 365 ADO.NET Provider お問い合わせ

Outlook Mail、Calendar、Contact などのOffice 365 データへの双方向連携を.NET アプリケーションに実装。