How to convert .xlsx to .csv

HI

Iam trying to convert .xlsx file to .csv without using write csv activity

just want to convert

Please help me with the possible mathod

Thanks in advance

@jai_kumar2
Did you try Vb Code?

  1. Use the “Excel Application Scope” activity:
  • Drag and drop the “Excel Application Scope” activity onto your workflow.
  • Set the WorkbookPath property to the path of your .xlsx file.
  1. Use the “Read Range” activity:
  • Inside the “Excel Application Scope,” add the “Read Range” activity.
  • Specify the range of cells you want to read from the .xlsx file or leave it empty to read the entire sheet.
  • Set the DataTable output property to store the data from the .xlsx file.
  1. Use the “Write Text File” activity:
  • Outside of the “Excel Application Scope,” add the “Write Text File” activity.
  • Set the FileName property to the desired output .csv file path.
  • In the “Content” field, use the following expression to convert the DataTable to CSV format:
String.Join(Environment.NewLine, dataTable.AsEnumerable().Select(Function(row) String.Join(",", row.ItemArray)))
  • Set the Append property to False to overwrite the file if it already exists.
  1. Save and run your workflow to convert the .xlsx file to .csv.

Hi @jai_kumar2

Use the Read range workbook activity to read the excel file and store it in a datatable. Use the Write csv activity to write the same datatable to csv file. It was the simple process.

Hope it helps!!

Hi @jai_kumar2

To convert an .xlsx file to .csv format in UiPath without using the “Write CSV” activity, you can use the following steps:

  1. Use the “Excel Application Scope” activity to open the Excel file.
  2. Within the scope of “Excel Application Scope,” use the “Read Range” activity to read the data from the Excel file into a DataTable variable.
  3. Create a new StringBuilder variable to store the CSV data.
  4. Use a “For Each Row” activity to iterate through each row in the DataTable.
  5. Within the loop, use a “For Each” activity to iterate through each column in the row.
  6. Append the column value to the StringBuilder variable, followed by a comma (,) to separate the values.
  7. After the inner loop, use an “Assign” activity to append a newline character (Environment.NewLine) to the StringBuilder variable.
  8. After the outer loop, use the “Write Text File” activity to write the content of the StringBuilder variable to a .csv file.

Thanks!!

Hi @jai_kumar2

You can check this once:

@jai_kumar2

  1. Use read range activity and then read the data into datatable
  2. Use output datatable activity which will convert your datatable dt to string str
  3. Now use write text file and give str as data input and filename as a .csv instead of .txt

Cheers

Hi @jai_kumar2

By using Rename File activity you can convert your .xlsx file to .csv file

image

image

Regards,