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?
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.
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.
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.
Save and run your workflow to convert the .xlsx file to .csv.
mkankatala
(Mahesh Kankatala)
July 7, 2023, 5:42pm
3
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!!
Nitya1
(Nitya Tomar)
July 7, 2023, 6:00pm
4
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:
Use the “Excel Application Scope” activity to open the Excel file.
Within the scope of “Excel Application Scope,” use the “Read Range” activity to read the data from the Excel file into a DataTable variable.
Create a new StringBuilder variable to store the CSV data.
Use a “For Each Row” activity to iterate through each row in the DataTable.
Within the loop, use a “For Each” activity to iterate through each column in the row.
Append the column value to the StringBuilder variable, followed by a comma (,
) to separate the values.
After the inner loop, use an “Assign” activity to append a newline character (Environment.NewLine
) to the StringBuilder variable.
After the outer loop, use the “Write Text File” activity to write the content of the StringBuilder variable to a .csv file.
Thanks!!
lrtetala
(Lakshman Reddy)
July 8, 2023, 8:55am
7
Hi @jai_kumar2
By using Rename File activity you can convert your .xlsx file to .csv file
Regards,