UiPath Documentation
studiox
2022.4
false
StudioX 用户指南
重要 :
新发布内容的本地化可能需要 1-2 周的时间才能完成。

教程:使用来自 Excel 的数据在 Acrobat Reader 中填充 PDF 表单

在本教程中,我们将创建一个自动化的流程,为公司的每个新员工创建一个设备使用协议 PDF 表格。自动化从模板表单开始,为每个员工创建一个表单,并使用其中包含有关每个员工所接收设备之信息的 Excel 文件中的数据填充该表单。

我们首先添加创建文件夹活动,以创建用于保存 PDF 文件的文件夹。然后,我们添加一个使用应用程序/浏览器活动,其中包含使用 Excel 文件活动。这些活动会将 Acrobat Reader 中打开的模板文件,以及带有设备数据的 Excel 文件添加到自动化中。在“使用 Excel 文件”中,我们将添加遍历 Excel 行活动,以逐行处理文件。在“遍历 Excel 行”中,一系列键入活动可将每行单元格的数据复制到 PDF 表单,然后“键盘快捷键” 、 “单击”和“键入”活动会执行在 Acrobat Reader 中为每个输入创建单独的 PDF 所需的任务员工。

  1. 步骤 1:设置项目并下载必要的文件。

    1. 使用此页面底部的按钮,下载并解压缩本教程中自动化项目的存档文件。将文件 EquipmentAgreement.pdfEmployees.xlsx 复制到您的项目文件夹,然后双击 PDF 文件以在 Acrobat Reader 中将其打开。

    2. 在 Acrobat Reader 中,将“页面布局”设置为“单页”,将“缩放”设置为“默认”。这样做是为了确保在运行自动化时,屏幕上可以显示整个表格,以便 Robot 可填写表格。在 Acrobat Reader DC 中,您可以通过选择“编辑” > “首选项” > “页面显示”来更改这些设置。

      备注:

      Note: If you encounter problems indicating elements in Acrobat Reader, update accessibility options for the document as described in Identifying UI Elements in PDF With Accessibility Options in the Studio Guide.

  2. 第 2 步:创建一个文件夹并将文件添加到项目中。

    1. Click Add activity 文档图像 in the Designer panel, and then find the Create Folder activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    2. 在“创建文件夹”活动中,单击加号文档图像单击“文件夹名称”字段右侧的,然后选择“文本” 。在文本生成器中,输入EquipmentAgreements

      您已表明要在项目文件夹中创建一个名为 EquipmentAgreements 的文件夹。

    3. Click Add activity 文档图像 below Create Folder, and then find the Use Application/Browser activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    4. 在“使用应用程序/浏览器”活动中:

      • 单击“指定应用程序”,然后将鼠标指针移至打开 PDF 的 Acrobat 窗口。当窗口以蓝色突出显示时,请单击窗口中的任意位置。

        “使用应用程序/浏览器”活动已更新,该活动内会显示窗口的屏幕快照,“应用程序路径”字段中会显示可执行文件的路径。

      • 单击字段右侧的“加号”文档图像 (在“应用程序参数”字段右侧),然后选择“文本” 。在文本生成器中,输入EquipmentAgreement.pdf

        您已表明希望自动化在 Adobe Acrobat 中打开文件 EquipmentAgreement.pdf。

    5. Click Add activity 文档图像 inside Use Application/Browser, and then find the Use Excel File activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    6. 在“使用 Excel 文件”活动中:

      • Click Browse文档图像 next to the Excel file field, and then browse to and select the file Employees.xlsx.

      • 在“引用为”字段中,输入 EmployeeData

        您已表明将使用在自动化中称为 EmployeeData 的 Employees.xlsx 文件。

  3. 第 3 步:添加活动以重复 Excel 文件中的每一行。

    将每个员工的值从 Excel 文件复制到 PDF 表单,每个 PDF 与员工名称一起保存在新创建的文件夹中。

    1. Click Add activity 文档图像 inside Use Excel File, and then find the For Each Excel Row activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    2. 在“遍历 Excel 行”活动中:

      • Click Plus文档图像 on the right side of the In range field, and then select EmployeeData > Sheet1 [Sheet]

      • 在“遍历”字段中,输入 Employee

        您已指明要针对 EmployeeData 文件中 Sheet1 中的每一行重复活动。由于每一行都包含有关员工的数据,因此在自动化中称其为 Employee,从而使以后在自动化中从中选择数据变得更加容易。以便稍后在自动化中更容易从中选择数据。

    3. Click Add activity 文档图像 inside For Each Excel Row, and then find the Type Into activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    4. 在“键入到”活动中:

      • 单击“在屏幕上指定目标”,然后将鼠标指针移到 EquipmentAgreement.pdf 文件中的“名字”字段上,并在该字段突出显示后单击该字段。文本字段将被标识为目标,其旁边的“名字”标签被标识为锚点。在“选择选项”窗口中单击“确认”以保存选择。目标和锚点的图像显示在“键入到”活动中。

      • 单击字段右侧的“加号”文档图像“输入此项”字段右侧,然后选择“员工” > “名字”

        您已指明要针对每个员工复制“名字”列中的值并将其粘贴到 PDF 表单的“名字”字段中。

    5. 在先前的“键入到”活动下方添加另四个“键入到”活动。使用步骤 3-4 中的说明,配置活动以复制每个员工的“姓氏”、“公司中的角色”、“设备型号”和“设备序列号”,然后将其粘贴到 PDF 表单的相应字段中。

    6. 在“遍历 Excel 中的行”活动中,在最后一个“键入到”活动之后,添加第六个“键入到”活动。

    7. 在“键入到”活动中:

      • 单击“在屏幕上指定目标”,然后将鼠标指针移到 EquipmentAgreement.pdf 文件中的“全名”字段上,并在该字段突出显示后单击该字段。文本字段将被标识为目标,其旁边的“全名”标签被标识为锚点。在“选择选项”窗口中,单击“确认”以保存选择。目标和锚点的图像显示在“键入到”活动中。

      • 单击字段右侧的“加号”文档图像然后选择“文本”

        在文本生成器中撰写一个文本,其中包含 Excel 文件中每个员工的名字和姓氏,并用空格分隔:

        1. Click Plus文档图像 on the right side, and then select Employee > First Name.
        2. 添加一个空格。
        3. Click Plus文档图像 on the right side, and then select Employee > Last Name.
        4. 单击“保存”

      您已指明要针对每个员工复制“名字”列和“姓氏”列中的值,并将其粘贴到 PDF 表单的“全名”字段中。

      1. 在“遍历 Excel 中的行”活动中,在最后一个“键入到”活动之后,添加第七个“键入到”活动。
    8. 在“遍历 Excel 中的行”活动中,在最后一个“键入到”活动之后,添加第七个“键入到”活动。

    9. 在“键入到”活动中:

      • 单击“在屏幕上指定目标”,然后将鼠标指针移到 EquipmentAgreement.pdf 文件中的“日期”字段上,并在该字段突出显示后单击该字段。文本字段将被标识为目标,其旁边的“日期”标签被标识为锚点。在“选择选项”窗口中,单击“确认”以保存选择。目标和锚点的图像显示在“键入到”活动中。
      • Click Plus 文档图像 on the right side of the Type this field, and then select Project Notebook (Notes) > Date [Sheet] > Today [Cell].

      您已指明要针对每个员工从项目笔记本的一个单元格中复制今天的日期,并将其粘贴到 PDF 表单的“日期”字段中。

    10. Click Add activity 文档图像 below the last Type Into activity inside For Each Excel Row and then find the Keyboard Shortcuts activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    11. 在“键盘快捷键”活动中,单击“记录快捷键”,然后在键盘上按以下组合键:CTRL SHIFT S

      您已指明要通过按 CTRL + SHIFT + S来保存 PDF 文件。执行自动化后,此组合将在 Acrobat Reader 中打开“另存为”对话框。

    12. 在打开文件的 Acrobat Reader 窗口中,按键盘上的 CTRL SHIFT S 以打开“另存为”对话框。

    13. In StudioX, click Add activity 文档图像 below the Keyboard Shortcuts activity inside For Each Excel Row, and then find the Click activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    14. 在“点击”活动中,单击“在屏幕上指定目标”,然后将鼠标指针移至“另存为”对话框中的“选择其他文件夹”按钮上,并在该按钮突出显示后,单击该按钮。该按钮将被标识为目标,其旁边的“取消”按钮被标识为锚点。在“选择选项”窗口中,单击“确认”以保存选择。目标和锚点的图像显示在“点击”活动中。

      You have indicated that you want to click Choose a different folder to open the Save as dialog in the file explorer. 15. In the Acrobat Reader window where the file is opened, click Choose a different folder in the Save as dialog.

    15. 在 StudioX 功能区中,选择“项目” > “打开项目文件夹”,以在文件资源管理器中打开项目文件夹,然后从地址(位置)栏中将完整路径复制到文件夹。

    16. In StudioX, click Add activity 文档图像 below the Click activity inside For Each Excel Row, and then find the Use Application/Browser activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

    17. 在“使用应用程序/浏览器”活动中,单击“指定应用程序” ,然后将鼠标指针移至 Acrobat 中的“另存为”对话框。当对话框以蓝色突出显示时,请单击框中的任意位置。

      “使用应用程序/浏览器”活动已更新,该活动内会显示窗口的屏幕快照,“应用程序路径”字段中会显示可执行文件的路径。

    18. Click Add activity 文档图像 inside the newly added Use Application/Browser, and then find the Type Into activity in the search box at the top of the screen and select it. The activity is added to the Designer panel.

      在“键入到”活动中:

      • 单击“在屏幕上指定目标”,然后将鼠标指针移到“另存为”对话框中的“文件名称”字段上,并在该字段突出显示后单击该字段。该字段将被标识为目标,其旁边的“文件名称”标签被标识为锚点。在“选择选项”窗口中,单击“确认”以保存选择。目标和锚点的图像显示在“键入到”活动中。

      • 单击字段右侧的“加号”文档图像然后选择“文本”

        在文本生成器中:

        文本应如下图所示:

        1. 粘贴在第 16 步中复制的路径。
        2. 输入 \EquipmentAgreements\EquipmentAgreement_
        3. Click Plus文档图像 on the right side, and then select Employee > First Name.
        4. Click Plus文档图像 on the right side, and then select Employee > Last Name.
        5. Click Plus文档图像 on the right side, and then select Special Keys > Enter.
        6. 单击“保存”

      您已表明要使用包含员工姓名的文件名在 EquipmentAgreements 文件夹中保存各 PDF 文件。

      “遍历 Excel 中的行”活动应如下图所示(对于较大的视图,请右键单击该图像并将其保存):

    19. 在 StudioX 功能区中单击“保存”,以保存此自动化。

    20. 为避免在执行过程中出现任何问题,请确保在 Adobe Acrobat 中没有打开 PDF 文件。然后单击“运行”以执行自动化。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新