COnversion of Excel file to .txt file

How do i convert excel file to .txt file? Can anyone pls show an example worflow?

Hi @HarshithRao
Welcome to uipath community buddy
–use excel application scope and pass the excel file path as input
–use read range activity and get the output as a variable of type datatable named outdt
–use output datatable activity and pass the above varaible as input and get the output as a structured string variable named out_text

–use write text activity and pass the variable out_text as input
https://activities.uipath.com/docs/write-text-file

Thats all buddy you are done
Cheers @HarshithRao

1 Like

Thankyou for the detailed explanation. :smiley:

Did this get resolved buddy
Cheers @HarshithRao

Hi @Palaniyappan
Is it possible to do this on studioX? i want to save a CSV as .txt using studioX

Otherwise by adding the dependency “Microsoft.Office.Interop.Excel” in uipath studio with a block “Invoke code”, the following code does the same thing directly without external program.
Source : Conversion of Excel file to .txt file with little program .NET

 Dim MyExcel As  Microsoft.Office.Interop.Excel.Application =  New  Microsoft.Office.Interop.Excel.Application
 
 Dim FileExcel as String= "C:\Users\Uipath\Downloads\File.xls"

        Dim Book  as Microsoft.Office.Interop.Excel.Workbook= MyExcel.Workbooks.Open(FileExcel, False, True)

        Dim Sheet As Microsoft.Office.Interop.Excel.Worksheet = DirectCast(Book.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)

        Dim R As Integer = Sheet.Rows.Count
        Dim C As Integer = Sheet.Columns.Count

        Console.WriteLine("R = " + R.ToString)
        Console.WriteLine("C = " + C.ToString)

		   Dim div As Integer = C 
        Dim colLetter As String = String.Empty
        Dim modnum As Integer

        While div > 0
            modnum = (div - 1) Mod 26
            colLetter = Chr(65 + modnum) & colLetter
            div = CInt((div - modnum) \ 26)
        End While
		
		
        Dim Table As Object(,)

        Table = DirectCast(Sheet.Range("A1:" + colLetter + R.ToString).Value, Object(,))

        Dim txt As String = ""
        For Row As Integer = 1 To CInt(Table.Length / C)
            Dim subtxt As String = ""
            For i As Integer = 1 To C
                If Table(Row, i) IsNot Nothing Then
                    subtxt += Table(Row, i).ToString + vbTab
                End If
            Next
            If subtxt.Length > 0 Then txt += subtxt + vbCrLf
        Next
		
		File.WriteAllText(FileExcel + "V2.txt", txt)
         Book.Close(False)

Hi,
Read the Excel file by using read range activity store it in one data table DT and use write CSV file and pass the data table DT to write CSV and FileName name extension should be .txt instead of .csv I think it’s work