Table of Contents

  1. Overview

  2. Why Convert Excel to Text Formats?

  3. Key Benefits of Aspose.Cells LowCode TextConverter

  4. Prerequisites

  5. Step-by-Step Conversion Guide

  6. Complete C# Code Example

  7. Performance Optimization Tips

  8. Common Issues & Troubleshooting

  9. Frequently Asked Questions (FAQs)

  10. Related Resources


Overview

The Aspose.Cells.LowCode TextConverter simplifies converting Excel spreadsheets into various text formats, such as CSV, TSV, XML, SLK, and DIF. This tool is essential for data interchange, ETL pipelines, and integration with legacy systems.


Why Convert Excel to Text Formats?

  • Data Integration & ETL: Easily integrate spreadsheet data into databases, analytics systems, and data warehouses.
  • Legacy System Compatibility: Communicate with older systems that require plain text inputs.
  • Readable and Maintainable Data: Simplify data review and management with human-readable formats.

Key Benefits of Aspose.Cells LowCode TextConverter

  • Extensive Format Support: Easily convert to CSV, TSV, XML, SLK, DIF, SQLSCRIPT, and more.
  • Simple API Usage: Quickly convert using minimal code with a single method call.
  • Accurate Round-Trips: Convert back and forth between Excel and text formats without data loss.
  • Flexible Encoding: Easily manage file encoding through streams or custom configurations.

Prerequisites

  1. Install the latest version of Aspose.Cells.LowCode via NuGet:

Install-Package Aspose.Cells.LowCode

  1. .NET 6.0 or later.
  2. Required namespaces:
using Aspose.Cells;
using Aspose.Cells.LowCode;

Step-by-Step Conversion Guide

Excel to CSV

Convert Excel spreadsheets directly into CSV format:

var loadOptions = new LowCodeLoadOptions { InputFile = "contacts.xlsx" };
var saveOptions = new LowCodeSaveOptions { SaveFormat = SaveFormat.Csv, OutputFile = "contacts.csv" };
TextConverter.Process(loadOptions, saveOptions);

CSV to Excel

Import CSV data back into an Excel workbook:

var loadOptions = new LowCodeLoadOptions { InputFile = "contacts.csv" };
var excelOptions = new LowCodeSaveOptions { SaveFormat = SaveFormat.Xlsx, OutputFile = "contacts.xlsx" };
TextConverter.Process(loadOptions, excelOptions);

Other Formats (TSV, SLK, XML)

Convert Excel to other text formats with ease:

saveOptions.SaveFormat = SaveFormat.Tsv;  // Also supports SLK, XML
TextConverter.Process(loadOptions, saveOptions);

Complete C# Code Example

A complete, executable C# program demonstrating conversion between Excel and CSV:

using System;
using Aspose.Cells.LowCode;

namespace TextConversionExample
{
    class Program
    {
        static void Main()
        {
            // Excel to CSV
            var excelLoadOpts = new LowCodeLoadOptions { InputFile = "report.xlsx" };
            var csvSaveOpts = new LowCodeSaveOptions { SaveFormat = SaveFormat.Csv, OutputFile = "report.csv" };
            TextConverter.Process(excelLoadOpts, csvSaveOpts);
            Console.WriteLine("Excel to CSV conversion completed.");

            // CSV to Excel
            var csvLoadOpts = new LowCodeLoadOptions { InputFile = "report.csv" };
            var excelSaveOpts = new LowCodeSaveOptions { SaveFormat = SaveFormat.Xlsx, OutputFile = "report_converted.xlsx" };
            TextConverter.Process(csvLoadOpts, excelSaveOpts);
            Console.WriteLine("CSV to Excel conversion completed.");
        }
    }
} 

Performance Optimization Tips

  • Manage Large Datasets: Convert large files in chunks or stream data line-by-line.
  • Scheduled Automation: Use batch processing or scheduled tasks to automate recurring conversions.
  • Custom Delimiter Handling: Apply custom delimiters using additional scripting or the full Aspose.Cells API.

Common Issues & Troubleshooting

Error or IssueRecommended Solution
Unsupported SaveFormat errorsVerify the format matches supported types and correct file extensions.
Encoding errorsExplicitly specify encoding (e.g., Encoding.UTF8) when reading/writing.
Data truncation or misalignmentAdjust column widths or delimiters with full API options.

Frequently Asked Questions (FAQs)

Q1: Can headers be included in exported CSV? Yes, ensure the first Excel row contains headers.

Q2: How do I convert XML data back to Excel format? Set SaveFormat = SaveFormat.Xml in TextConverter.Process.

Q3: Does TextConverter support file compression? No direct compression; use .NET System.IO.Compression separately after conversion.



More in this category