UiPath Documentation
studiox
2024.10
true
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Guia do usuário do StudioX

Última atualização 13 de mai de 2026

Tutorial: Comparar arquivos do Excel e enviar e-mails com erros de reconciliação

Neste tutorial, criaremos uma automação para comparar os valores em uma planilha que contém faturas com os valores de um arquivo CSV que contém um resumo por fornecedor. Se ocorrer algum erro de reconciliação entre os arquivos, criaremos um arquivo CSV com detalhes e enviaremos o arquivo por e-mail.

Vamos criar um projeto com as seguintes atividades:

  1. Duas atividades Use Excel File para indicar o arquivo do Excel com as faturas e o arquivo no qual queremos reconciliar os dados.
  2. Uma série de atividades Write Cell para adicionar cabeçalhos de duas colunas ao arquivo de reconciliação do Excel e para calcular a soma total de faturas de um fornecedor e a diferença entre essa soma e o valor no resumo inicial. Adicionaremos uma atividade Copy Range para copiar as fórmulas que adicionamos para um fornecedor em todas as linhas da planilha, para que possamos executar os mesmos cálculos para todos os fornecedores. Em seguida adicione mais uma atividade Write Cell para adicionar a diferença total a uma célula.
  3. Uma atividade If na qual adicionaremos uma condição de que, se houver erros de reconciliação (a soma das diferenças é maior que 0), um arquivo CSV com detalhes deve ser criado e enviado por e-mail para um endereço especificado. Para as tarefas de e-mail, dentro da atividade If adicionaremos uma atividade Use Desktop Outlook App para indicar a conta do Outlook da qual queremos enviar o e-mail e uma atividade Send Email dentro de Use Desktop Outlook App.
  4. Configure o projeto e obtenha os arquivos necessários.
    1. Crie um novo projeto em branco usando as configurações padrão.
    2. Download and extract the archive with the automation project in this tutorial using the button at the bottom of this page. Copy the folder data to your project folder.
  5. Adicione os arquivos do Excel ao projeto.
    1. Click Add Activity Imagem dos documentos 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. Na atividade:
      • Click Browse Imagem dos documentos next to the Excel file field, and then browse to and select the file invoices.xlsx

      • No campo Referenciar como, insira Invoices.

        Você indicou que irá trabalhar no arquivo invoices.xlsx, que é conhecido em sua automação como Invoices.

    3. Click Add Activity Imagem dos documentos inside the Use Excel File activity, and then add a another Use Excel File activity.
    4. Na segunda atividade:
      • Click Browse Imagem dos documentos next to the Excel file field, and then browse to and select the file reconcile.xlsx

      • No campo Referenciar como, insira Rec.

        Você indicou que irá trabalhar no arquivo reconcile.xlsx, que é conhecido em sua automação como Rec.

  6. Copie os dados para o arquivo de reconciliação.
    1. Click Add Activity Imagem dos documentos 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. In the Read CSV activity:
      • Click Browse Imagem dos documentos next to the Read from file field, and then browse to and select the file summary.csv.

      • Click Plus docs image on the right side of the Output to field, and then select Rec > Summary [Sheet]. The field is updated with your selection [Rec] Summary.

        Você indicou que deseja copiar os dados do arquivo CSV summary.csv para o arquivo Rec na Planilha Summary.

    3. Click Add Activity Imagem dos documentos 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. Na atividade Copy/Paste Range:
      • Click Plus docs image on the right side of the Source field, and then select Invoices > Invoices [Sheet]. Your selection is displayed in the field as [Invoices] Invoices.

        Você indicou que deseja copiar a planilha Invoices do arquivo Invoices.

      • Click Plus docs image on the right side of the Destination field, and then select Rec > Invoices [Sheet]. Your selection is displayed in the field as [Rec] Invoices.

        Você indicou que deseja colar o intervalo copiado na planilha Invoices no arquivo Rec.

  7. Faça os cálculos necessários para comparar os dados.
    1. No painel Atividades, selecione a guia Excel, arraste a atividade Write Cell e solte-a no segundo Use Excel File abaixo de Copy/Paste Range. Uma atividade Write Cell será adicionada ao painel Designer.
    2. Na atividade Write Cell:
      • Click Plus Imagem dos documentos on the right side of the What to write field, and then select Text. In the Text Builder, enter the text Calculated Amount.

      • Click Plus docs image on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell C1, and then click Confirm. The field is updated with your selection [Rec] Summary!C1.

        Você indicou que deseja que a primeira célula na coluna C da planilha Summary do arquivo Rec contenha o texto Calculated Amount.

    3. Adicione uma segunda atividade Write Cell abaixo da anterior e, na atividade:
      • Click Plus Imagem dos documentos 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), "").

      • Click Plus docs image on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell C2, and then click Confirm. The field is updated with your selection [Rec] Summary!C2.

        Você indicou que deseja que a célula C2 da planilha Summary no arquivo Rec contenha a fórmula =IF(A2 <> "", SUMIF(Invoices!B:B, A2, Invoices!C:C), ""). Essa fórmula verifica se a célula do fornecedor (A2) não está vazia e soma os valores na coluna C da planilha Invoices com os do fornecedor na célula A2 da planilha Summary.

    4. Adicione uma terceira atividade Write Cell abaixo da anterior e, na atividade:
      • Click Plus Imagem dos documentos on the right side of the What to write field, and then select Text. In the Text Builder, enter the text Difference.

      • Click Plus docs image on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell D1, and then click Confirm. The field is updated with your selection [Rec] Summary!D1.

        Você indicou que deseja que a primeira célula na coluna D da planilha Summary no arquivo Rec contenha o texto Difference.

    5. Adicione uma quarta atividade Write Cell abaixo da anterior e, na atividade:
      • Click Plus Imagem dos documentos 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, "").

      • Click Plus docs image on the right side of the Where to write field, and then select Rec > Indicate in Excel. The spreadsheet is opened in Excel. Select the cell D2, and then click Confirm. The field is updated with your selection [Rec] Summary!D2.

        Você indicou que deseja que a célula D2 da planilha Summary no arquivo Rec contenha a fórmula =IF(A2 <> "", C2-B2, ""). Essa fórmula verifica se a célula do fornecedor (A2) não está vazia e calcula a diferença entre os valores nas células C2 e B2 da planilha Summary.

    6. Click Add Activity Imagem dos documentos 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. Na atividade Copy/Paste Range:
      • Click Plus Imagem dos documentos on the right side of the Source 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 Imagem dos documentos on the right side of the Destination 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.

      • No menu suspenso O que copiar, selecione Formulas

        Você indicou que deseja colar a fórmula no intervalo copiado C2:D2 abaixo nas mesmas colunas da planilha.

    8. No painel Atividades, selecione a guia Excel, arraste a atividade Write Cell e solte-a abaixo da última atividade Copy/Paste Range. Uma atividade Write Cell será adicionada ao painel Designer.
    9. Na atividade Write Cell:
      • Click Plus Imagem dos documentos 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).

      • Click Plus docs image on the right side of the Where to write field, 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.

        Você indicou que deseja que a primeira célula na coluna F da planilha Invoices no arquivo Rec contenha a fórmula =SUM(Summary!D:D). A fórmula adiciona a soma das diferenças na coluna D da planilha Summary à célula F1 na planilha Invoices.

  8. Enviar um e-mail com detalhes sobre a conciliação se a soma das diferenças for maior que 0.
    1. Click Add Activity Imagem dos documentos 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, select Imagem dos documentos Open in Advanced Editor next to the Condition field to open the Condition Builder.

    3. No Construtor de Condição, adicione a condição "se a soma das diferenças for maior que 0":

      • Click Plus Imagem dos documentos 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.

      • From the drop-down menu in the middle, select greater than.

      • Click Plus docs image on the right side of the field on the right, select Number, enter 0 and click Save twice.

        As atividades que você adiciona na ramificação Then da atividade If serão executadas se essa condição for atendida.

    4. No painel de atividades, selecione a aba CSV , arraste a atividade Write CSV e solte-a na ramificação Then da atividade If. Uma atividade Write CSV é adicionada ao painel Designer.

    5. Na atividade Write CSV:

      • Click Plus Imagem dos documentos 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 Imagem dos documentos menu on the right side of the Text Builder select Notebook > Date [Sheet] > YYYYMMDD [Cell]. The text in the Text Builder is updated to reconcile-[Notes] Date!YYYYMMDD. Enter the text .csv at the end and click Save. The final text should be reconcile-[Notes] Date!YYYYMMDD.csv.

      • Click Plus docs image on the right side of the Write from field, and then select Rec > Summary [Sheet]. The field is updated with your selection [Rec] Summary.

        Você indicou que deseja criar um arquivo CSV na pasta do projeto contendo a palavra Reconciliar no nome junto da data de hoje e que quer copiar nele a planilha Summary do arquivo Rec.

    6. No painel Atividades, selecione a guia E-mail e, em seguida, arraste a atividade Use Desktop Outlook App e solte-a na ramificação Then da atividade If abaixo da atividade Write CSV.

    7. Na atividade, a conta de e-mail padrão já está selecionada no campo Conta. Se você quiser usar uma conta diferente, selecione-a no menu suspenso.

      Na campo Referenciar como, deixe o valor padrão Outlook como o nome pelo qual se referir à conta na automação.

    8. No painel Atividades, arraste a atividade Send Email e solte-a dentro da atividade Use Desktop Outlook App.

    9. Na atividade Send Email:

      • Click Plus Imagem dos documentos on the right side of the Account field, and then select Outlook.

      • Click Plus Imagem dos documentos 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 Save as draft option selected, the automation does not send the email, it instead saves the email to the Outlook Drafts folder.

      • Click Plus Imagem dos documentos 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 Imagem dos documentos menu on the right side of the Text Builder select Notebook > Date [Sheet] > Today [Cell]. The text in the Text Builder is updated to Reconciliation errors for [Notes] Date!Today.

      • Click Plus Imagem dos documentos 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..

      • Para Anexos, selecione Arquivos e insira o mesmo nome do arquivo usado na atividade Write CSV na etapa 5, reconcile-[Notes] Date!YYYYMMDD.csv. Por exemplo, você pode abrir o Construtor de Texto para o campo Escrever em qual arquivo da atividade Write CSV, copiar todo o texto e depois colar no Construtor de Texto para o campo de anexo de arquivos.

    10. Clique em Salvar na faixa de opções do StudioX para salvar a automação e clique em Executar para executar a automação. As faturas e os dados de resumo são copiados para o arquivo reconcile.xlsx, os cálculos são executados e, como o valor total nas faturas não corresponde ao uma no resumo para um dos fornecedores, a planilha Summary do arquivo reconcile.xsls será copiada para o arquivo CSV cujo nome inclui a data de hoje, o arquivo será anexado a um e-mail e enviado ao endereço especificado. No arquivo, você pode identificar o fornecedor com os erros de reconciliação pelo valor na célula D3 que é maior que 0. Baixe o exemplo

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades