1
3

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】大量データをExcelに貼り付ける

Last updated at Posted at 2019-12-17

コレクションに大量データを突っ込んで、Excel VBOのWrite Collectionで貼り付けようとしたらフリーズしました。。。
データ量は2000件くらいだったかと思います。

今回はフリーズしない方法を考えてみました。
結論、データを小分けにして貼り付ける方法を取りました。

実験1. CSVにして貼り付ける

大量データをCSVデータ化した後、セルにペタッと貼り付けてはどうか?

今回は大量データのコレクションを用意する必要があったため、Excelに予め2000行のデータを用意しておき、コレクションとして読み込ませます。

image.png

コードステージに、コレクションからCSVに変換するコードを用意して実行したところ、OutOfMemoryで落ちました。断念。。。

Dim count As Long = 0		
For Each r As DataRow In Collection_In.Rows		
  Dim recordCsv As String	
  For Each c As DataColumn In Collection_In.Columns	
    If count = 0 Then
      recordCsv = recordcsv & c.ColumnName + ","
    Else
      recordCsv = recordcsv & r(c.ColumnName) + ","
    End If
  Next	
  result = result & recordCsv.Substring(0, recordCsv.length-1) & Environment.NewLine	
Next		

image.png

実験2. データを小分けにする

結果的に、この方法で最後まで実行することができました。
より速い方法はありそうですが、取り急ぎフリーズせずに処理を完遂できたのでOKとします(笑)

Input

「ファイルパス」は無くても良いです。(大量データ読込用のため)
「分割行数」は、何レコード単位でExcelに書き込みにいくかを設定するためのパラメータです。

image.png

オブジェクト全体像

Inputの「分割行数」で設定した行数単位でExcelに貼り付けていきます。

ExcelVBOの「Go To Next Empty Cell Down」は空セルを上から探していくアクションですが、
値が入っているセルのうち、最も右下のセルを取得してしまいます。なので、A列に修正する処理を入れて列を固定するようにしています。

その他、細かい実装はGitHubにアップしているサンプルをご覧下さい。
image.png

サンプル

https://github.com/falcslab/blueprism/tree/collection
BPA オブジェクト - Excelにコレクションを貼り付ける.xml

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?