Table to Word Document

Hi Guys,

I have the following situation. First I have a list of vendors with their specific address like this in an Excel file:

Vendor Address
Vendor1 Address1
Vendor2 Address2

What a I need is to get this and then put this new table in a Word Document:

Vendor1 Vendor2
Address1 Address2

Any idea?

Hi @CP2208

  1. Transpose the data in the DataTable so that the vendors become columns and their addresses become rows. Create a new DataTable or List to store the transposed data.
  2. Use insert datatable in document activity.
    UiPath.Word.Activities

This will give you a better idea of what I need in the Word document

image

Hi,

But how do I transpose the first datatable?

Hi @CP2208

  1. Read the vendor and address data from the Excel file into a DataTable.
  2. Create a new DataTable to hold the transformed data in the desired format.
  3. Loop through the rows of the original DataTable and populate the new DataTable with the vendor and address information in the desired format.
  4. Use the Write Range activity to write the new DataTable back to a new Excel file.
  5. Use the Word activities in UiPath to create a Word document and insert a table with the data from the new Excel file.

Regards,

@CP2208

  1. Excel Application Scope (Provide the path to your Excel file)

    1. Read Range (Read the data into a DataTable variable, let’s call it dtExcelData)
  2. Assign (Create two lists to store vendors and addresses)

    • vendorsList = New List(Of String)
    • addressesList = New List(Of String)
  3. For Each Row (In dtExcelData)

    • Assign (Populate the lists)
      • vendorsList.Add(row(“Vendor”).ToString)
      • addressesList.Add(row(“Address”).ToString)
  4. Assign (Transpose the lists)

    • transposedData = {vendorsList.ToArray, addressesList.ToArray}
  5. Word Application Scope (Provide the path to your Word document)

    1. Add Table Row (For the header row)

      • Column 1: “Vendor”
      • Column 2: “Address”
    2. For Each item In transposedData

      • Add Table Row
        • Column 1: item(0).ToString
        • Column 2: item(1).ToString
  6. Save and Close Word Document

@CP2208

Check this:

Hi @CP2208

Please find the below xaml of workflow total changes are done.

AddressInfo.zip (169.3 KB)

O/P:
Address.docx (12.2 KB)

I hope it helps!!

Hi,

I tried an activity called “Transpose Datatable” and then the Insert DataTable in Document as you suggested and everything went Ok. So I marked your proposal as solution.

Many thanks to everybody

1 Like

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