New to Telerik Document ProcessingStart a free 30-day trial

Using TxtFormatProvider

Updated on Jun 16, 2026

TxtFormatProvider makes it easy to import and export TXT files. TXT is a plain text format and holds only the contents of the worksheet without its formatting. Export to this format strips all styling and saves only the cell result value with the applied format, using tab as a delimiter. The provider exports only the contents of the active worksheet. Import from TXT creates a new workbook with a single worksheet named Sheet1.

To import and export TXT files, you need an instance of TxtFormatProvider, which is contained in the Telerik.Windows.Documents.Spreadsheet.FormatProviders.TextBased.Txt namespace. The TxtFormatProvider implements the IWorkbookFormatProvider interface that appears in the Telerik.Windows.Documents.Spreadsheet.FormatProviders namespace.

For more examples and application scenarios of importing and exporting a Workbook to various formats using a FormatProvider, check out the Import/Load and Export/Save RadSpreadProcessing Workbook knowledge base article.

Import

Example 1 shows how to import a TXT file using a FileStream. The sample creates a TxtFormatProvider instance and passes a FileStream to its Import() method:

Example 1: Import TXT File

C#
Workbook workbook;
string fileName = "input.txt";
Telerik.Windows.Documents.Spreadsheet.FormatProviders.TextBased.Txt.TxtFormatProvider formatProvider = new TxtFormatProvider();

using (Stream input = new FileStream(fileName, FileMode.Open))
{
    workbook = formatProvider.Import(input, TimeSpan.FromSeconds(10));
}

Export

Example 2 demonstrates how to export an existing Workbook to a TXT file. The snippet creates a new workbook with a single worksheet, creates a TxtFormatProvider, and invokes its Export() method:

Example 2: Export TXT File

C#
Workbook workbook = new Workbook();
workbook.Worksheets.Add();

string fileName = "SampleFile.txt";
TxtFormatProvider formatProvider = new TxtFormatProvider();

using (Stream output = new FileStream(fileName, FileMode.Create))
{
    formatProvider.Export(workbook, output, TimeSpan.FromSeconds(10));
}

See Also

In this article
ImportExportSee Also
Not finding the help you need?
Contact Support