Table of Contents
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
- Install the latest version of Aspose.Cells.LowCode via NuGet:
Install-Package Aspose.Cells.LowCode
- .NET 6.0 or later.
- 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 Issue | Recommended Solution |
---|---|
Unsupported SaveFormat errors | Verify the format matches supported types and correct file extensions. |
Encoding errors | Explicitly specify encoding (e.g., Encoding.UTF8 ) when reading/writing. |
Data truncation or misalignment | Adjust 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.
Related Resources
More in this category
- How to Automate Excel in .NET with Aspose.Cells.LowCode
- Convert Excel to Images Using Aspose.Cells for .NET Plugin
- Convert Excel to JSON and JSON to Excel with Aspose.Cells for .NET
- How to Lock and Protect Excel Spreadsheets with Aspose.Cells for .NET
- Excel to PDF: Aspose.Cells PDF Converter Plugin for .NET