UiPath Documentation
studiox
2022.10
false
StudioX ユーザー ガイド
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

チュートリアル: Excel ファイルを比較し、照合エラーのメールを送信する

このチュートリアルでは、請求書が保存されたスプレッドシートにある金額と、サプライヤーごとのサマリーが保存された CSV ファイルにある金額を比較するうかプロジェクトを作成します。これらのファイル間に何らかの照合エラーが発生した場合、その詳細情報を記述した CSV ファイルを作成して、メールで送信します。

以下のアクティビティから成るプロジェクトを作成します。

  1. 請求書を含む Excel ファイルを指定するための [ Excel ファイルを使用 ] アクティビティ 2 つと、データを照合するためのファイルを指定します。

  2. 一連の [セルに書き込み ] アクティビティで照合 Excel ファイルに 2 つの列見出しを追加し、1 つのサプライヤーの合計請求額、およびその額と初期サマリー額との差額を計算します。1 つのサプライヤーを対象に追加した数式を、シートにあるすべての行にコピーする [ 範囲をコピー ] アクティビティを追加します。これにより、すべてのサプライヤーに対して同じ計算が実行されるようにします。つづいて、[セルに書き込み] アクティビティをもう 1 つ追加し、セルに差額の合計を書き込みます。

  3. [ 条件分岐 (if )] アクティビティ: このアクティビティには、照合エラーが発生した場合 (差額の合計が 0 より大きい場合) に、その詳細を記述した CSV ファイルを作成し、指定したアドレスにメールで送信するという条件を追加します。メール タスクのため、[条件分岐 (if)] アクティビティ内に [ デスクトップ版 Outlook アプリを使用 ] アクティビティを追加してメールを送信する Outlook アカウントを指定します。さらに、[デスクトップ版 Outlook アプリを使用] 内に [メールを送信 ] アクティビティを追加します。

  4. 手順 1: プロジェクトを設定し、必要なファイルを取得する

    1. Create a new blank project using the default settings.
    2. このチュートリアルでは、このページ下部にあるボタンを使用して、オートメーション プロジェクトを収めたアーカイブをダウンロードして展開します。プロジェクト フォルダーに data フォルダーをコピーします。
  5. 手順 2: Excel ファイルをプロジェクトに追加する

    1. Click Add activity ドキュメントの画像 in the Designer panel, and then find the Use Excel File activity in the search box at the top of the screen and select it. A Use Excel File activity is added to the Designer panel.

    2. アクティビティで次の操作を行います。

      • Click Browseドキュメントの画像 next to the Excel file field, and then browse to and select the file invoices.xlsx

      • [参照名] フィールドに「Invoices」と入力します。

        これで、このオートメーションでは名前を Invoices としたファイル invoices.xlsx を操作対象として指定したことになります。

    3. Click Add activity ドキュメントの画像 inside the Use Excel File activity, and then add a another Use Excel File activity.

    4. 2 番目のアクティビティで、次の操作を行います。

      • Click Browseドキュメントの画像 next to the Excel file field, and then browse to and select the file reconcile.xlsx

      • [参照名] フィールドに「Rec」と入力します。

        これで、このオートメーションでは名前を Rec としたファイル reconcile.xlsx を操作対象として指定したことになります。

  6. 手順 3: データを照合ファイルにコピーする

    1. Click Add activity ドキュメントの画像 inside the second Use Excel File, and then find the Read CSV activity in the search box at the top of the screen and select it. The activity is added inside the Use Excel File activity.

    2. [CSV を読み込み] アクティビティで、以下の手順を実行します。

      • Click Browseドキュメントの画像 next to the Read from file field, and then browse to and select the file summary.csv.

      • Click Plus ドキュメントの画像 on the right side of the Output to field, and then select Rec > Summary [Sheet]. The field is updated with your selection [Rec] Invoices.

        これで、CSV ファイル summary.csv のデータを、Rec ファイルの Summary シートにコピーするように指定したことになります。

    3. Click Add activity ドキュメントの画像 inside the second Use Excel File below the Read CSV activity, and then find the Copy Range activity in the search box at the top of the screen and select it. A Copy Range activity is added inside the Use Excel File activity.

    4. [範囲をコピー] アクティビティで、次の操作を行います。

      • Click Plus ドキュメントの画像 on the right side of the Source range field, and then select Invoices > Invoices [Sheet]. Your selection is displayed in the field as [Invoices] Invoices.

        これで、Invoices ファイルから Invoices シートをコピーするように指定したことになります。

      • Click Plus ドキュメントの画像 on the right side of the Destination range field, and then select Rec > Invoices [Sheet]. Your selection is displayed in the field as [Rec] Invoices.

        これで、コピーした範囲を Rec ファイルの Invoices シートに貼り付けるように指定したことになります。

  7. 手順 4: データ比較に必要な計算を実行する

    1. [アクティビティ] パネルで [Excel] タブを選択し、[セルに書き込み] アクティビティを 2 番目の [Excel ファイルを使用] 内の [範囲をコピー] の下にドラッグ アンド ドロップします。[セルに書き込み] アクティビティがデザイナー パネルに追加されます。

    2. [セルに書き込み] アクティビティで、以下の手順を実行します。

      • Click Plusドキュメントの画像 on the right side of the What to write field, and then select Text. In the Text Builder, enter the text Calculated Amount.

      • [ ドキュメントの画像書き込む場所] フィールドの右側にある プラス 記号 をクリックし、[ Rec] > [ Excel 内で示す] を選択します。スプレッドシートが Excel で開きます。セル C1 を選択して [ 確定] をクリックします。フィールドの内容が、選択した [Rec] Summary で更新されます。C1.

        これで、Rec ファイルにある Summary シートの C 列の一番上のセルに、テキスト「Calculated Amount」を書き込むように指定したことになります。

    3. 前の [セルに書き込み] アクティビティの下に、もう 1 つ同じアクティビティを追加します。

      • Click Plusドキュメントの画像 on the right side of the What to write field, and then select Text. In the Text Builder, enter the text =IF(A2 <> "", SUMIF(Invoices!B:B, A2, Invoices!C:C), "").

      • [ ドキュメントの画像書き込む場所] フィールドの右側にある プラス 記号 をクリックし、[ Rec] > [ Excel 内で示す] を選択します。スプレッドシートが Excel で開きます。セル C2 を選択して [ 確定] をクリックします。フィールドの内容が、選択した [Rec] Summary で更新されます。C2.

        これで、Rec ファイルにある Summary シートの C2 セルに、数式「=IF(A2 <> "", SUMIF(Invoices!B:B, A2, Invoices!C:C), "")」を書き込むように指定したことになります。この数式は、サプライヤーのセル (A2) が空でないことを確認し、Summary シートの A2 セルに記述されたサプライヤーについて、Invoices シートの C 列の値を合計します。

    4. 前の [セルに書き込み] アクティビティの下に、3 番目の同じアクティビティを追加して、そこで以下の手順を実行します。

      • Click Plusドキュメントの画像 on the right side of the What to write field, and then select Text. In the Text Builder, enter the text Difference.

      • [ ドキュメントの画像書き込む場所] フィールドの右側にある プラス 記号 をクリックし、[ Rec] > [ Excel 内で示す] を選択します。スプレッドシートが Excel で開きます。セル D1 を選択して [ 確定] をクリックします。フィールドの内容が、選択した [Rec] Summary で更新されます。D1.

        これで、Rec ファイルにある Summary シートの D 列の一番上のセルに、テキスト「Difference」を書き込むように指定したことになります。

    5. 前の [セルに書き込み] アクティビティの下に、4 番目の同じアクティビティを追加して、そこで以下の手順を実行します。

      • Click Plusドキュメントの画像 on the right side of the What to write field, and then select Text. In the Text Builder, enter the text =IF(A2 <> "", C2-B2, "").

      • [ ドキュメントの画像書き込む場所] フィールドの右側にある プラス 記号 をクリックし、[ Rec] > [ Excel 内で示す] を選択します。スプレッドシートが Excel で開きます。セル D2 を選択し、[ 確定] をクリックします。フィールドの内容が、選択した [Rec] Summary で更新されます。D2.

        これで、Rec ファイルにある Summary シートの D2 セルに、数式「=IF(A2 <> "", C2-B2, "")」を書き込むように指定したことになります。この数式は、サプライヤーのセル (A2) が空でないことを確認し、Summary シートのセル C2 と B2 の値の差を計算します。

    6. Click Add activity ドキュメントの画像 below the last Write Cell activity, and then find the Copy Range activity in the search box at the top of the screen and select it. A Copy Range activity is added to the Designer panel.

    7. [範囲をコピー] アクティビティで、次の操作を行います。

      • Click Plusドキュメントの画像 on the right side of the Source range field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the range C2:D2, and then click Confirm. The field is updated with your selection [Rec] Summary!C2:D2.

      • Click Plusドキュメントの画像 on the right side of the Destination range field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the range C3-D20, and then click Confirm. The field is updated with your selection [Rec] Summary!C3-D20.

      • [コピーする内容] ドロップダウン メニューの [数式] を選択します。

        これにより、コピーしたセル範囲 C2:D2 の数式を、シートにある同じ列の下の行にコピーするように指定したことになります。

    8. [アクティビティ] パネルの [Excel] タブを選択し、[セルに書き込み] アクティビティを最後の [範囲をコピー] アクティビティの下にドラッグ アンド ドロップします。[セルに書き込み] アクティビティがデザイナー パネルに追加されます。

    9. [セルに書き込み] アクティビティで、以下の手順を実行します。

      • Click Plusドキュメントの画像 on the right side of the What to write field, and then select Text. In the Text Builder, enter the formula =SUM(Summary!D:D).

      • [ ドキュメントの画像書き込む場所] フィールドの右側にある プラス 記号 をクリックし、[ Rec] > [ Excel 内で示す] を選択します。スプレッドシートが Excel で開きます。Invoices シートを選択してから、セル F1 を選択して [ Confirm (確定)] をクリックします。フィールドの内容が、選択した [Rec] Invoices (請求書) で更新されます。F1 です。

        これで、Rec ファイルにある Invoices シートの F 列の一番上のセルに、数式「=SUM(Summary!D:D)」を書き込むように指定したことになります。この数式は、Summary シートの D 列に表示された差の合計であり、Invoices シートの F1 セルに追加されます。

  8. 手順 5: 差額の合計が 0 より大きい場合に、照合に関する詳細をメールで送信する

    請求書 (invoices) とサマリー (summary) のデータがファイル reconcile.xlsx にコピーされ、計算が実行されます。サプライヤーの 1 社で、請求書の合計額がサマリーの額と一致しないため、ファイル reconcile.xlsx の Summary シートが、今日の日付を使用した名前の CSV ファイルにコピーされます。このファイルがメールに添付され、指定したアドレスに送信されます。添付ファイルのセル D3 の値が 0 より大きいことから、照合エラーのあるサプライヤーを特定できます。

    1. Click Add activity ドキュメントの画像 below the last Write Cell activity, and then, in the search box at the top of the screen, locate and select If. An If activity is added to the Designer panel.

    2. In the If activity, click Plus ドキュメントの画像 on the right side of the Condition field, and then select Condition Builder.

    3. 次の手順に従い、[条件ビルダー] で「差額の合計が 0 より大きい場合」という条件を追加します。

      • Click Plusドキュメントの画像 on the right side of the field on the left, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the sheet Invoices, then the cell F1, and then click Confirm. The field is updated with your selection [Rec] Invoices!F1.

      • 中央のドロップダウン メニューから [次の値より大きい] を選択します。

      • 右側のフィールドの右側にあるプラス記号 ドキュメントの画像 をクリックし、[数値] を選択します。0 を入力して [保存] を 2 回クリックします。

        この条件が満たされた場合、[条件分岐 (if)] アクティビティの [Then] 分岐に追加したアクティビティが実行されます。

    4. [アクティビティ] パネルの [ CSV ] タブを選択し、[ CSV に書き込み ] アクティビティを [条件分岐 (if)] アクティビティの [Then] 分岐にドラッグ アンド ドロップします。[CSV に書き込み] アクティビティがデザイナー パネルに追加されます。

    5. [CSV に書き込み] アクティビティで、以下の手順を実行します。

      • Click Plusドキュメントの画像 on the right side of the Write to what file field, and then select Text. In the Text Builder, enter reconcile, and then from the Plusドキュメントの画像 menu on the right side of the Text Builder select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text in the Text Builder is updated to reconcile Excel Date!YYYYMMDD. Enter the text .csv at the end and click Save. The final text should be reconcile Excel Date!YYYYMMDD.csv.

      • ドキュメントの画像[書き込み元] フィールドの右側にある プラス 記号 をクリックし、[ Rec >の Summary[シート]] を選択します。フィールドの内容が、選択した [Rec] Summary で更新されます。

        これで、reconcile という語と今日の日付を名前に持つ CSV ファイルをプロジェクト フォルダーに作成し、そのファイルにRec ファイルの Summary シートをコピーするように指定したことになります。

    6. [アクティビティ] パネルで [メール] タブを選択し、[デスクトップ版 Outlook アプリを使用] アクティビティを、[条件分岐 (if)] アクティビティの [Then] 分岐内の [CSV に書き込み] アクティビティの下にドラッグ アンド ドロップします。

    7. このアクティビティの [アカウント] フィールドには、あらかじめ既定のメール アカウントが入力されています。別のアカウントを使用する場合は、ドロップダウン メニューから選択します。

      [参照名] フィールドは既定値 Outlook のままとして、オートメーションでアカウントを参照するときは、この名前を使用します。

    8. [アクティビティ] パネルで [メールを送信] アクティビティをドラッグし、[デスクトップ版 Outlook アプリを使用] アクティビティ内にドロップします。

    9. [メールを送信] アクティビティで、以下の手順を実行します。

      • Click Plusドキュメントの画像 on the right side of the From account field, and then select Outlook.

      • Click Plusドキュメントの画像 on the right side of the To field, and then select Text. In the Text Builder window, enter an email address where to send the email. For example, you can enter your own email address to send the email to yourself. If you leave the Is draft option selected, the automation does not send the email, it instead saves the email to the Outlook Drafts folder.

      • Click Plusドキュメントの画像 on the right side of the Subject field, and then select Text. In the Text Builder window, enter Reconciliation errors for, and then from the Plusドキュメントの画像 menu on the right side of the Text Builder select Project Notebook (Notes) > Date [Sheet] > Today [Cell]. The text in the Text Builder is updated to Reconciliation errors for Date!Today.

      • Click Plusドキュメントの画像 on the right side of the Body field, and then select Text. In the Text Builder window, enter text for the body of the email, for example One or more suppliers have reconciliation errors. See attached CSV file for details..

      • [添付ファイル]で [ファイル] を選択し、手順 5 で [CSV に書き込み] アクティビティに使用したものと同じファイル名「reconcile Excel Date!YYYYMMDD.csv」を入力します。たとえば、[CSV に書き込み] アクティビティの [書き込み先ファイル] フィールドでテキスト ビルダーを開き、すべてのテキストをコピーし、ファイル添付フィールドのテキスト ビルダーに貼り付けることができます。

    10. StudioX のリボンで [保存] をクリックしてオートメーションを保存し、[実行] をクリックしてオートメーションを実行します。

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得