How to convert a file .xlsx to .txt

Hello everybody! :slight_smile:

I want to convert an excel file (.xlsx) from Sharepoint to a text file (.txt). I’m trying to do it with the activity “assign” but i cant because my excel file is a DriveItem and i think it can only be done with a String.

Can somebody help me?


We can use a simple method of reading that excel and writing to a txt file like this

  1. 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


You can use this activity


Hi @Palaniyappan!

I have tried the first option but i get the same error, the output is a DataTable and the “Write text” activity needs a String variable.

Also I don’t see the “Save Excel file as” activity in the “excel activities” package, should I install another one?

If u are using community edition then we can use All the activities that are available in StudioX can be used in Studio and Studio Pro. Click View Options filter activities|autoxautofilter activities|autoxauto at the top of the Activities panel, and then select Show StudioX . The StudioX activities available in the packages installed for the current project are listed in the StudioX category.


This activity only lets me convert to this options:

But appart, using the first option you give to me, the write text activity, I have managed to get a text file, the problem is that it creates it with commas and with the columns:

I need it to look like this:

Separated by spaces and without column headers.

Thanks @Palaniyappan!

when writing to text file, do
out_text.Replace(",", vbTab)

Then it will look like this

Hello again, I don’t think this solution works for me, because I have a column with prices and it replaces the commas in the decimals with blanks.

This is how I would like it to appear:

And this is how it appears to me, replace commas with spaces:


I don´t know how to fix that.

@ELISA_ARTALEJO_BARINAGA Try with the below post. It is almost similar but instead of pdf try changing to .txt

instead of
out_text.Replace(",", vbTab)

do this
system.Text.RegularExpressions.Regex.Replace(out_text, "(?!\B"+Chr(34)+"[^"+Chr(34)+"]*),(?![^"+Chr(34)+"]*"+Chr(34)+"\B)", vbTab)

Example Input


I got this error:

This activity only works for PDF, as it says in the activity itself. Even if I put “.txt” it is saved as a PDF.

whats the full value of text?

and make sure its actually inputted here

I put the same thig you say to me but with the name of my file (TablaAtxt):

system.Text.RegularExpressions.Regex.Replace( TablaAtxt, “(?!\B”+Chr(34)+"[^"+Chr(34)+"]),(?![^"+Chr(34)+"]"+Chr(34)+"\B)", vbTab)

i think your TablaAtxt value is null, you can try print it before write text file

make sure it has a value before write text file

e.g. make sure read text file is outputting the text to TablaAtxt

is not null because it works with the other option → out_text.Replace(",", vbTab)

are TablaAtxt and out_text two different variables?

if out_text is the output of your file then it should be

system.Text.RegularExpressions.Regex.Replace( out_text, “(?!\B”+Chr(34)+"[^"+Chr(34)+"] ),(?![^"+Chr(34)+"] “+Chr(34)+”\B)", vbTab)

sorry it works with TablaAtxt.Replace(",", vbTab)

can you upload your xaml file and text file here

use the string variable containing all this text, not the variable containing the name of your file


Read the Excel range and use Write csv with a following properties
Filepath : a.txt
Delimiter: Tab
Add headers : check box

Happy automation :slight_smile: