Excelに画像を挿入したい。

UiPath StudioX を使用しております。

繰り返し(各行)アクティビティで
列Aのセルの値と同じファイル名の画像を列Bに挿入(または貼り付け)したいのですが、
そのようなことは可能でしょうか?

(列A) (列B)
りんご りんご.png を挿入
ぶどう ぶどう.png を挿入

どうぞよろしくお願いいたします。

→ First, make sure you have the image files (e.g., Apple.png, Grape.png) in a folder accessible to your UiPath StudioX project.
→ Open UiPath StudioX and create a new project or open an existing one.
->Add an Excel file to the project containing the data in columns A and B as shown in your example.
→ Use the “Excel For Each Row” activity to loop through each row in the Excel file.
→ Inside the loop, use the “Assign” activity to get the value of the cell in Column A and store it in a variable, let’s call it fruitName.
→ Use the “Assign” activity again to create a new variable, let’s call it imagePath, which is the path to the corresponding image file. You can combine the folder path where the images are located with the fruitName variable to get the correct image path.
→ Next, use the “Insert Image” activity to insert the image into Column B. Set the value of the “Image” property of this activity to the imagePath variable, and set the cell to insert the image into (e.g., B1).
->Add any necessary delay or wait activity if required to ensure smooth execution.
->The loop will repeat for each row in the Excel file, inserting the appropriate image into Column B based on the file name in Column A.

Regards,

→ まず、UiPath StudioX プロジェクトにアクセスできるフォルダーに画像ファイル (Apple.png、Grape.png など) があることを確認します。
→ UiPath StudioX を開いて新しいプロジェクトを作成するか、既存のプロジェクトを開きます。
->例に示すように、列 A と B のデータを含む Excel ファイルをプロジェクトに追加します。
→ 「Excel For Each Row」アクティビティを使用して、Excel ファイルの各行をループします。
→ ループ内で、「Assign」アクティビティを使用して列 A のセルの値を取得し、それを変数 (fruitName とします) に格納します。
→ 再度「Assign」アクティビティを使用して、新しい変数を作成します。これを imagePath と呼びます。これは、対応する画像ファイルへのパスです。画像が配置されているフォルダー パスと FruitName 変数を組み合わせて、正しい画像パスを取得できます。
→ 次に、「画像を挿入」アクティビティを使用して、B 列に画像を挿入します。このアクティビティの「画像」プロパティの値を imagePath 変数に設定し、画像を挿入するセル (例: B1) を設定します。
→ スムーズな実行を確保するために、必要に応じて、必要な遅延または待機アクティビティを追加します。
→ Excel ファイルの各行に対してループが繰り返され、列 A のファイル名に基づいて適切な画像が列 B に挿入されます。

@B_H_Akshatha_Pai

回答ありがとうございます!
「画像を挿入」アクティビティが無いのですが、
何かパッケージを追加したら使用できますでしょうか?

テンプレート ファイルに画像を配置するには、キーボード ショートカットを使用して Excel アクションを実行する必要があります。 UiPath StudioX には、画像を挿入するための直接的なアクティビティはありません。
「Excel > キーボード ショートカット」アクションを使用して、「Ctrl + C」で画像ファイルのパスをコピーし、「Ctrl + V」で列 B の適切なプレースホルダーに貼り付けるなどのキーボード ショートカットを実行します。
列 B の目的のセルで「Ctrl + V」を使用して、画像パスを貼り付けます。 Excel は、そのパスに関連付けられた画像を自動的に挿入します。またはホットキーを使用する

こんにちは

StudioXですとなかなか厳しいのですが、例えば以下の様になると思います。

NewBlankTask20230725-1.zip (57.8 KB)

1 Like

@Yoichi

サンプルを作成いただきありがとうございます!

「メソッドを呼び出し」アクティビティで下記のようなエラーが出てきてしまったのですが
どこか設定が足りないのでしょうか?

どうぞよろしくお願いいたします。

これは上記サンプルでしょうか?あるいは別で作ったものでしょうか?
もし後者なら、パラメータープロパティの内容を確認ください。

@Yoichi

後者でした。
パラメータープロパティの内容を直したところ、画像が貼り付けされました!
ありがとうございました!

1 Like

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