1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【BluePrism】コレクションの行列変換を行う

Last updated at Posted at 2020-02-25

やりたいこと

コレクションの行列変換です。
既存のCollection ManipulationにTranspose Collectionがあるのですが、思ったのと違う結果が返ってきたので自作しました。

Input

image.png
image.png

結果

違うそうじゃない。
image.png

求めている結果

行と列を変換しています。
image.png

コード

きったないコードなので誰かリファクタリングお願いします(苦笑)

Try
	Dim New_Collection As DataTable
	New_Collection = New DataTable()

	'最大行列取得
	Dim maxRow, maxCol As Integer
	maxRow = Collection_In.Rows.Count
	maxCol = Collection_In.Columns.Count
	
	'フィールド作成,空行追加
	Dim tmpColCount As Integer = 0
	For Each r1 As DataRow In Collection_In.Rows
		New_Collection.Columns.Add("Column" & tmpColCount, Type.GetType("System.String"))
		tmpColCount = tmpColCount + 1
	Next
	For Each c1 As DataColumn In Collection_In.Columns
		Dim dr As DataRow
		dr = New_Collection.NewRow
		New_Collection.Rows.Add(dr)
	Next

	'データ登録
	Dim rowCount As Integer = 0
	Dim newColCount As Integer = 0
	While rowCount < maxRow
		Dim colCount As Integer = 0
		Dim newRowCount As Integer = 0
		For Each c3 As DataColumn In Collection_In.Columns
			New_Collection.Rows(newRowCount)("Column" & newColCount) = Collection_In.Rows(rowCount)(c3.ColumnName)
			newRowCount = newRowCount + 1
		Next
		newColCount = newColCount + 1
		rowCount = rowCount + 1
	End While

    Transpose_Collection = New_Collection.DefaultView.ToTable
    Success = True
    Message = ""
Catch e As Exception
    Success = False
    Message = e.Message
End Try

注意

行列変換後のコレクションは、全列の型が「テキスト」になります。
パスワード型やフラグ型のパラメータはテキスト表記されるので、注意してください。
(例)パスワード型の場合 ⇒ 変換前:●●●●●●●● 変換後:Password
(例)フラグ型の場合 ⇒ 変換前:True 変換後:True(文字列)

サンプル

https://github.com/falcslab/blueprism/tree/collection
BPA オブジェクト - コレクション行列変換.xml

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?