Text is one frequently used file format, which is formed with texts in lots of columns. It is attached in Windows operation system. Therefore, it is easy to create and open a TXT file.
Because its simple structure, TXT file is widely used to save text information. It is easy to recover if there are some errors in file. Also, txt file has small size and easy to save. However, there are not so much format tools provided, just including font type, color and size setting.
Sometimes, we need to use txt file to save data to avoid some problems which exists because of format. We can export data to txt file directly or convert other format files which save data to txt. In this post, I will show way to convert Excel to txt with C#.
In my example, I want to convert one Excel file about sales report to txt file. And I use Spire.XLS in this method. So, I add its DLL file as reference.
- Load the file which I want to convert to txt from my computer and initialize the current worksheet.
- Save this file to txt and launch this file.
static void Main(string args)
//Load File and Initialize Worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile(@”D:\work\My Documents\Sales Report.xlxs”,ExcelVersion.Version2010);
Worksheet sheet = workbook.Worksheets;
//Save to TXT
//Launch TXT File
Click Here to LEARN MORE about Spire.XLS
Click Here to DOWNLOAD Spire.XLS