# データテーブルを結合後の出力内容について

**URL:** <https://forum.uipath.com/t/topic/791585>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, excel, system, activities\
**Created:** [December 25, 2024, 3:20am UTC](https://forum.uipath.com/t/topic/791585 "2024-12-25T03:20:47Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 25, 2024, 3:20am UTC](https://forum.uipath.com/t/topic/791585/1 "2024-12-25T03:20:47Z")

</div>

２つのExcelを番号で結合して、その内容の一部を片方のExcelに書き込む作業をしています。  
結合内容を確認していたのですが、結合の種類をInner、Left、Fullのどれに変えても、フィルターをかけてみてもDataTableをExcelに書き出してみるとどれも同じに見えるのですが、これは結合に失敗しているということでしょうか？

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 25, 2024, 3:25am UTC](https://forum.uipath.com/t/topic/791585/2 "2024-12-25T03:25:07Z")

</div>

こんにちは  
どのようなデータテーブルに対して、どの列をキーにしたか、とその結果を共有いただくと良いかと思います。

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 25, 2024, 3:42am UTC](https://forum.uipath.com/t/topic/791585/3 "2024-12-25T03:42:47Z")

</div>

AのExcelのL列（契約番号（連番））とBのExcelのJ列（契約連番）をイコールで結合しています。  
結合した結果はBのExcelの結合結果シートです。  
よろしくお願いいたします  
[データ結合.zip](https://forum.uipath.com/uploads/short-url/9EtmlmtEc81QSELdiqLRHcqb9n0.zip) (288.1 KB)

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 25, 2024, 3:58am UTC](https://forum.uipath.com/t/topic/791585/4 "2024-12-25T03:58:53Z")

</div>

InnerJoinで期待する結果は得られると思います。

 ![image](https://global.discourse-cdn.com/uipath/original/4X/0/a/a/0aa7c3b110427166071277ba87b4e2ac1b5d4f40.png)

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 25, 2024, 4:50am UTC](https://forum.uipath.com/t/topic/791585/5 "2024-12-25T04:50:54Z")

</div>

ありがとうございます。  
何らかの原因で元々の方は上手くいってなかったようです。  
教えていただいた方法でできたと思いますが、やはり結合した内容を書き出そうとするとうまくいきません。  
そもそも私がしようとしていることが合っているのかを確認したいのですが  
AのExcelのF列（納品年月日を）BのExcelのP列に入力したい場合、  
AとBを結合して、Excelファイルを使用でBのExcelを指定して、セルに書き込みで書き込む内容のところに結合した変数（dt結合）を使用して、「dt結合.Columns(“納品年月日”)」を入れるという方法で合っていますか？

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 25, 2024, 5:14am UTC](https://forum.uipath.com/t/topic/791585/6 "2024-12-25T05:14:25Z")

</div>

> [@marita](#):
>
> dt結合.Columns(“納品年月日”)

これはDataColumnが返りますので、実データは入りません。

結合前のDataTableの元となるワークシートに書き込む要件があるようでしたら、  
InnerJoinではなく、各行ごとに対象有無チェック、必要な情報を取得・書き込みのロジックを入れいるか、  
あるいはBから読み込んだデータテーブルに行番号列を追加して、InnerJoin後、その情報を元に書き込むべきアドレスを割り出してから書き込む方法等が考えられます。

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 25, 2024, 6:40am UTC](https://forum.uipath.com/t/topic/791585/7 "2024-12-25T06:40:04Z")

</div>

結合は使わない方が良いということですね。  
前者の方が良い気がしますが、アクティビティで言うとデータテーブルを検索⇒セルに書き込みという感じでしょうか？

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 25, 2024, 6:44am UTC](https://forum.uipath.com/t/topic/791585/8 "2024-12-25T06:44:10Z")

</div>

最終的にB.xlsxに対して書き戻すのであれば、B.xlsxに対して繰り返し（EXCELの各行）アクティビティで繰り返し、各行の当該情報をA.xlsxから読み込んだDataTableに対してマッチング（データテーブルを検索アクティビティでも良いかと思います。）、必要データを取得して、`CurrentRow("書き戻す列") = 値` のようにすれば良いかと思います。

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 25, 2024, 7:40am UTC](https://forum.uipath.com/t/topic/791585/9 "2024-12-25T07:40:20Z")

</div>

データテーブルを検索アクティビティの使い方を調べて入れてみましたが、認識が合っているか確認させてください。  
今回の場合、ルックアップを実行するデータテーブルでBのExcelを指定して検索する列もExcel内で指定していますが合っていますか？  
添付の画像のようになっているんですが、列と列番号のところには何を入れたら良いのか分からないので、何が対象になるのか教えていただけますでしょうか？

 ![The screenshot shows a "Lookup Data Table" activity configuration in UiPath Studio, used to search for specific values in an Excel sheet. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/f/7/5/f75ea59715222b3c9a2e844f898fa0146820a94f.png)

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 25, 2024, 1:55pm UTC](https://forum.uipath.com/t/topic/791585/10 "2024-12-25T13:55:58Z")

</div>

DataTable操作系のアクティビティを使うのであれば、一旦ワークシートの中身を変数として取り込んで処理したほうが良いかと思います。  
なお列、列名、列番号はいずれか１つのみが設定できます。（複数することはできません）

公式ドキュメントを確認すると良いかと思います。

> **[アクティビティ - データ テーブルを検索](https://docs.uipath.com/ja/activities/other/latest/workflow/lookup-data-table)**
>
> The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...

あるいはEXCELのワークシートを直接操作したいのであればVLookUpのアクティビティ等もありますので、こちらを使う手もあります。

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 26, 2024, 2:52am UTC](https://forum.uipath.com/t/topic/791585/11 "2024-12-26T02:52:44Z")

</div>

ありがとうございます。  
色々方法が出てきて、どれが良いのか分からなくなってきてしまいました💦  
過去の質問を見ていると [https://forum.uipath.com/t/excel-vlookup/708567](https://forum.uipath.com/t/excel-vlookup/708567)  
こちらの投稿が私の実現したいことと似ているので、Dictionaryを使用する方法が良いのではないかと考えています。  
今回私が使いたいのは文字列ではなく数字なので使えないでしょうか？

 ![The image shows two side-by-side screenshots of Excel spreadsheets with various data fields highlighted in green and yellow. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/e/1/1/e11673e903ffe53eaed599c7159772eeb886bdc9.png)

私の場合はAのExcelの契約連番をキーにして、BのExcelの契約連番を探して、対象があればP列にAのExcelの納品年月日を入れようとしています。  
同じように作ってみましたが、うまく書き込めず数値だからかなと考えています。

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 26, 2024, 3:42am UTC](https://forum.uipath.com/t/topic/791585/12 "2024-12-26T03:42:41Z")

</div>

> [@marita](#):
>
> 過去の質問を見ていると [Excel vlookupアクティビティの使用方法](https://forum.uipath.com/t/excel-vlookup/708567)  
> こちらの投稿が私の実現したいことと似ているので、Dictionaryを使用する方法が良いのではないかと考えています。  
> 今回私が使いたいのは文字列ではなく数字なので使えないでしょうか？

整数を文字列化してもよいですし、整数のままキーとしても使えます。例えば`Dictionary<Int32, DateTime>`のような型にすればこちらの方法でも可能です。

このあたりは要件：どの程度の数量をどの程度の時間内に処理しないといけないか  
や  
保守性：これをメンテナンスする人が容易に保守できるか

といった点から適切なロジックを選択する必要があるかと思います。

ちなみにDictionary＋LINQ使った実装例は下記になります。（一旦その他欄に書き出しています）

 ![image](https://global.discourse-cdn.com/uipath/original/4X/2/1/a/21aec55054f357bbb41884df8829e546bdf6b4b4.png)

Sample  
[Sample20241226-2.zip](https://forum.uipath.com/uploads/short-url/3WgnVTIzanBjSqBtvB1ZwRFB6Eh.zip) (571.0 KB)

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 26, 2024, 5:57am UTC](https://forum.uipath.com/t/topic/791585/13 "2024-12-26T05:57:19Z")

</div>

ありがとうございます。  
大変助かりました。  
最後に質問させていただきたいのですが、ワークブックの範囲を読み込みとExcelの範囲を読み込みを使い分けておられますが、それはなぜでしょうか？  
AのExcelはワークブックの方のアクティビティを使われていたので気になりました。  
処理速度の問題でしょうか？

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [December 26, 2024, 6:05am UTC](https://forum.uipath.com/t/topic/791585/14 "2024-12-26T06:05:00Z")

</div>

> [@marita](#):
>
> 最後に質問させていただきたいのですが、ワークブックの範囲を読み込みとExcelの範囲を読み込みを使い分けておられますが、それはなぜでしょうか？

実際には互換性の問題や、パフォーマンスの問題等を総合的に評価する必要がありますが、今回は単にAの方はアクティビティ一つで済むから、Bの方は書き戻しが発生するので、念のため互換性優先でEXCELアプリケーションを経由する方法を採りました。一貫してEXCELアプリケーションを通じた方法でも問題ないと思います。

---

<div class="post-metadata">

**Author:** ![marita](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marita/32/176617_2.png) [@marita](https://forum.uipath.com/u/marita)\
**Post date:** [December 26, 2024, 6:12am UTC](https://forum.uipath.com/t/topic/791585/15 "2024-12-26T06:12:17Z")

</div>

勉強になります。ありがとうございました。

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [December 29, 2024, 6:12am UTC](https://forum.uipath.com/t/topic/791585/16 "2024-12-29T06:12:44Z")

</div>

Closed on December 29, 2024, 6:12am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
