0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Power Automate DesktopでDataTableの列数を取得する(Power Fx有効化前提)

0
Last updated at Posted at 2026-03-23

概要

Power Automate DesktopでDataTableを扱う際、「列数を取得したい」というケースがあります。

本記事では、「.NET スクリプトの実行(VB.NET)」アクションを利用して、DataTableの列数を取得する方法を紹介します。
※Power Fxを有効化した状態で説明しています。

実装方法

「.NET スクリプト実行」アクションを使用し、言語には「VB.NET」を指定します。
本実装では、以下を行います。

' dtInput(DataTable)の列数を取得
OutColumnCount = dtInput.Columns.Count

これだけです。

スクリプトパラメーター設定

以下のように 入力値(In)と出力値(Out)を設定します。

入力値(In)

  • dtInput
    DataTable 型
    列数を取得したい対象の DataTable

出力値(Out)

  • OutColumnCount
    整数型
    取得した列数を格納する変数

指定セルの値を取得したい場合

あわせて、例えば1行目・指定列の値を取得したい場合は、以下のようにコードを書きます。

' 1行目の2列目の値を取得する
OutValue = dtInput.Rows(0).Item(1).ToString()

' 2行目の5列目の値を取得する
OutValue = dtInput.Rows(1).Item(4).ToString()

' 列インデックスではなく、列名で指定も可能
OutValue = dtInput.Rows(0).Item("部署").ToString()

' Itemは省略可能
' 1行目の2列目の値を取得すると同じ意味
OutValue = dtInput.Rows(0)(1).ToString()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?