Skip to footer content
USING IRONXL

C# CSV to XLSX: Convert CSV Files to Excel Format

Converting CSV files to XLSX format unlocks spreadsheet capabilities that comma-separated values files simply cannot provide. While CSV stores raw tabular data, the Excel XLSX format supports formulas, multiple worksheets, charts, cell formatting, and data validation -- features that modern business applications demand. The conversion process is straightforward with the right library and takes just a few lines of C# code.

IronXL is a .NET library that handles this conversion directly, without requiring Microsoft Office or the Open XML SDK. It reads the source CSV file, parses the delimited data, and writes a fully compliant XLSX workbook. Install via NuGet and start a free trial to follow along with the code samples below.

How Do You Convert CSV Files to XLSX Format in C#?

The core conversion requires loading the CSV file and saving it in Excel format. IronXL provides WorkBook.LoadCSV, which parses the delimited source and creates a workbook ready for export. The method accepts the file path, the target Excel format, and the delimiter character.

using IronXL;

// Load CSV file and convert to XLSX format
WorkBook workbook = WorkBook.LoadCSV("data.csv", fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ",");

// Access the default worksheet containing CSV data
WorkSheet worksheet = workbook.DefaultWorkSheet;

// Save as Excel XLSX file
workbook.SaveAs("output.xlsx");
using IronXL;

// Load CSV file and convert to XLSX format
WorkBook workbook = WorkBook.LoadCSV("data.csv", fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ",");

// Access the default worksheet containing CSV data
WorkSheet worksheet = workbook.DefaultWorkSheet;

// Save as Excel XLSX file
workbook.SaveAs("output.xlsx");
Imports IronXL

' Load CSV file and convert to XLSX format
Dim workbook As WorkBook = WorkBook.LoadCSV("data.csv", fileFormat:=ExcelFileFormat.XLSX, ListDelimiter:=",")

' Access the default worksheet containing CSV data
Dim worksheet As WorkSheet = workbook.DefaultWorkSheet

' Save as Excel XLSX file
workbook.SaveAs("output.xlsx")
$vbLabelText   $csharpLabel

Output

C# CSV to XLSX: A Complete Developer Guide: Image 1 - Example output for CSV to Excel conversion

The LoadCSV method accepts three key parameters: the filename, the target Excel format constant, and the list delimiter used in the source file. This approach preserves all string data and numeric values from the original CSV sheet while creating a properly structured XLSX file. The WorkBook class serves as the central hub for all spreadsheet operations. Once loaded, the CSV data becomes accessible through worksheets, enabling further manipulation before saving the final Excel file.

For loading existing XLSX files instead of CSV, use WorkBook.Load("file.xlsx") which automatically detects the format from the file extension. This makes it straightforward to build pipelines that accept either CSV or Excel inputs and normalize them to a single output format.

What Are the Benefits of Converting CSV to Excel Format?

The XLSX format offers measurable advantages over plain CSV for most data management scenarios:

  • Multiple Worksheets: Excel files support multiple sheets within a single workbook, enabling organized data storage that CSV files cannot match. A single XLSX file can hold dozens of worksheets covering different time periods, regions, or categories.
  • Formula Support: Write complex calculations, aggregations, and conditional logic directly into cells. Excel formulas recalculate automatically when source data changes, eliminating the need to reprocess CSV files manually.
  • Visual Charts: Create bar charts, line charts, pie charts, and other visualizations from worksheet data. IronXL supports chart creation directly through the API, so charts are embedded in the XLSX file.
  • Cell Formatting: Control fonts, colors, borders, and number formats for professional documents. CSV files store only raw values; XLSX preserves the display layer alongside the data.
  • Data Validation: Restrict cell input to specific values or ranges, preventing data entry errors in files shared with end users.
  • Password Protection: Protect worksheets and workbooks with passwords to control read and write access, a feature entirely absent from CSV.

These capabilities make the XLSX format the standard choice for reports, dashboards, financial models, and any application requiring more than raw data storage.

How Do You Install IronXL in a .NET Project?

IronXL is distributed as a NuGet package. Install it from the Package Manager Console in Visual Studio:

Install-Package IronXl
Install-Package IronXl
SHELL

Or using the .NET CLI:

dotnet add package IronXl
dotnet add package IronXl
SHELL

After installation, add using IronXL; to any file that works with spreadsheets. The package targets .NET Framework 4.6.2+, .NET Core 3.1+, .NET 5 through .NET 10, and supports Windows, Linux, macOS, Docker, and Azure deployment environments.

No additional runtime dependencies or Microsoft Office installation are required. IronXL reads and writes XLSX files using its own parser and writer, making it suitable for server-side and headless deployments where Office cannot be installed.

How Do You Handle CSV Encoding During Conversion?

Many CSV files originate from legacy systems, international databases, or third-party exports that use non-ASCII characters. Handling encoding correctly ensures special characters and international text remain intact in the resulting XLSX file.

using IronXL;
using System.Text;

// Load CSV with explicit encoding specification
WorkBook workbook = WorkBook.LoadCSV("international-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",",
    encoding: Encoding.UTF8);

// Access the worksheet containing the encoded data
WorkSheet sheet = workbook.DefaultWorkSheet;

// Inspect a cell to verify encoding was preserved
string cellValue = sheet["A1"].StringValue;

// Save the converted Excel file
workbook.SaveAs("encoded-output.xlsx");
using IronXL;
using System.Text;

// Load CSV with explicit encoding specification
WorkBook workbook = WorkBook.LoadCSV("international-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",",
    encoding: Encoding.UTF8);

// Access the worksheet containing the encoded data
WorkSheet sheet = workbook.DefaultWorkSheet;

// Inspect a cell to verify encoding was preserved
string cellValue = sheet["A1"].StringValue;

// Save the converted Excel file
workbook.SaveAs("encoded-output.xlsx");
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output XLSX File

C# CSV to XLSX: A Complete Developer Guide: Image 2 - CSV to XLSX with all the encoding handled

IronXL automatically detects common encoding formats including UTF-8 for most standard CSV files. For files with non-standard encoding such as Windows-1252, ISO-8859-1, or Shift-JIS, pass the System.Text.Encoding instance to the LoadCSV call. The Encoding class documentation on Microsoft Learn lists all supported encoding names.

When fetching CSV data from a remote server, use HttpClient to download the stream, save it as a temporary file, and then load it through LoadCSV. This pattern works in cloud-hosted .NET applications where CSV files arrive as HTTP responses from third-party APIs.

How Do You Apply Cell Formatting After CSV Conversion?

Raw CSV data carries no formatting information. After converting to XLSX, apply number formats, fonts, and background colors to make the spreadsheet readable and professional.

using IronXL;
using IronXL.Styles;

// Load CSV data
WorkBook workbook = WorkBook.LoadCSV("sales-report.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

WorkSheet sheet = workbook.DefaultWorkSheet;

// Format the header row with bold text and background color
Range headerRow = sheet["A1:Z1"];
headerRow.Style.Font.Bold = true;
headerRow.Style.SetBackgroundColor("#4472C4");
headerRow.Style.Font.Color = "#FFFFFF";

// Apply currency format to a numeric column
Range priceColumn = sheet["C2:C100"];
priceColumn.Style.NumberFormat = "$#,##0.00";

// Auto-fit column widths for readability
sheet.AutoSizeColumn(0);
sheet.AutoSizeColumn(1);
sheet.AutoSizeColumn(2);

workbook.SaveAs("formatted-report.xlsx");
using IronXL;
using IronXL.Styles;

// Load CSV data
WorkBook workbook = WorkBook.LoadCSV("sales-report.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

WorkSheet sheet = workbook.DefaultWorkSheet;

// Format the header row with bold text and background color
Range headerRow = sheet["A1:Z1"];
headerRow.Style.Font.Bold = true;
headerRow.Style.SetBackgroundColor("#4472C4");
headerRow.Style.Font.Color = "#FFFFFF";

// Apply currency format to a numeric column
Range priceColumn = sheet["C2:C100"];
priceColumn.Style.NumberFormat = "$#,##0.00";

// Auto-fit column widths for readability
sheet.AutoSizeColumn(0);
sheet.AutoSizeColumn(1);
sheet.AutoSizeColumn(2);

workbook.SaveAs("formatted-report.xlsx");
Imports IronXL
Imports IronXL.Styles

' Load CSV data
Dim workbook As WorkBook = WorkBook.LoadCSV("sales-report.csv", fileFormat:=ExcelFileFormat.XLSX, ListDelimiter:=",")

Dim sheet As WorkSheet = workbook.DefaultWorkSheet

' Format the header row with bold text and background color
Dim headerRow As Range = sheet("A1:Z1")
headerRow.Style.Font.Bold = True
headerRow.Style.SetBackgroundColor("#4472C4")
headerRow.Style.Font.Color = "#FFFFFF"

' Apply currency format to a numeric column
Dim priceColumn As Range = sheet("C2:C100")
priceColumn.Style.NumberFormat = "$#,##0.00"

' Auto-fit column widths for readability
sheet.AutoSizeColumn(0)
sheet.AutoSizeColumn(1)
sheet.AutoSizeColumn(2)

workbook.SaveAs("formatted-report.xlsx")
$vbLabelText   $csharpLabel

IronXL exposes cell and range styling through the Style property, which mirrors the formatting options available in the Excel UI. Number formats follow the Excel number format syntax documented by Microsoft. The SetBackgroundColor method accepts hex color strings, making it straightforward to apply brand colors to generated reports. See the full cell formatting API reference for available style properties.

How Can You Add Charts After Converting CSV Data?

Once CSV data exists in an Excel workbook, IronXL enables creating charts directly from that data. Charts transform raw numbers into visual insights without requiring a Microsoft Excel installation on the server.

using IronXL;
using IronXL.Drawing.Charts;

// Load CSV and convert to Excel format
WorkBook workbook = WorkBook.LoadCSV("sales-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

WorkSheet worksheet = workbook.DefaultWorkSheet;

// Create a column chart from the converted CSV data
IChart chart = worksheet.CreateChart(ChartType.Column, 10, 0, 25, 10);

// Add data series from the worksheet ranges
IChartSeries series = chart.AddSeries("A2:A10", "B2:B10");
series.Title = "Monthly Sales";

// Configure chart appearance
chart.SetTitle("Sales Performance");
chart.SetLegendPosition(LegendPosition.Bottom);

// Plot the chart and save the workbook
chart.Plot();
workbook.SaveAs("sales-with-chart.xlsx");
using IronXL;
using IronXL.Drawing.Charts;

// Load CSV and convert to Excel format
WorkBook workbook = WorkBook.LoadCSV("sales-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

WorkSheet worksheet = workbook.DefaultWorkSheet;

// Create a column chart from the converted CSV data
IChart chart = worksheet.CreateChart(ChartType.Column, 10, 0, 25, 10);

// Add data series from the worksheet ranges
IChartSeries series = chart.AddSeries("A2:A10", "B2:B10");
series.Title = "Monthly Sales";

// Configure chart appearance
chart.SetTitle("Sales Performance");
chart.SetLegendPosition(LegendPosition.Bottom);

// Plot the chart and save the workbook
chart.Plot();
workbook.SaveAs("sales-with-chart.xlsx");
Imports IronXL
Imports IronXL.Drawing.Charts

' Load CSV and convert to Excel format
Dim workbook As WorkBook = WorkBook.LoadCSV("sales-data.csv", fileFormat:=ExcelFileFormat.XLSX, ListDelimiter:=",")

Dim worksheet As WorkSheet = workbook.DefaultWorkSheet

' Create a column chart from the converted CSV data
Dim chart As IChart = worksheet.CreateChart(ChartType.Column, 10, 0, 25, 10)

' Add data series from the worksheet ranges
Dim series As IChartSeries = chart.AddSeries("A2:A10", "B2:B10")
series.Title = "Monthly Sales"

' Configure chart appearance
chart.SetTitle("Sales Performance")
chart.SetLegendPosition(LegendPosition.Bottom)

' Plot the chart and save the workbook
chart.Plot()
workbook.SaveAs("sales-with-chart.xlsx")
$vbLabelText   $csharpLabel

Output

C# CSV to XLSX: A Complete Developer Guide: Image 3 - Output for converting CSV file into an Excel file with a chart

The CreateChart method accepts the chart type and four positioning parameters (top row, left column, bottom row, right column). The AddSeries method links worksheet cell ranges to chart axes, creating dynamic visualizations that update when the underlying data changes. IronXL supports column, bar, line, area, and pie chart types through the ChartType enum. For a complete list of supported chart configurations, see the IronXL chart tutorial.

How Do You Convert CSV to a DataTable and Then to Excel?

For scenarios requiring data manipulation before export, converting CSV data through a DataTable provides maximum flexibility. This approach lets developers filter, transform, sort, or validate rows during the conversion process using standard .NET data access patterns.

using IronXL;
using System.Data;

// Load CSV file into workbook
WorkBook sourceWorkbook = WorkBook.LoadCSV("input.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

// Convert worksheet to DataTable for manipulation
DataTable table = sourceWorkbook.DefaultWorkSheet.ToDataTable(true);

// Filter rows -- keep only rows where the third column value is greater than 100
DataRow[] filtered = table.Select("Column3 > 100");
DataTable filteredTable = filtered.Length > 0 ? filtered.CopyToDataTable() : table.Clone();

// Create new workbook from modified data
WorkBook outputWorkbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet outputSheet = outputWorkbook.CreateWorkSheet("Processed Data");

// Import filtered DataTable back into Excel
outputSheet.LoadFromDataTable(filteredTable, true);

// Save the final XLSX file
outputWorkbook.SaveAs("processed-output.xlsx");
using IronXL;
using System.Data;

// Load CSV file into workbook
WorkBook sourceWorkbook = WorkBook.LoadCSV("input.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

// Convert worksheet to DataTable for manipulation
DataTable table = sourceWorkbook.DefaultWorkSheet.ToDataTable(true);

// Filter rows -- keep only rows where the third column value is greater than 100
DataRow[] filtered = table.Select("Column3 > 100");
DataTable filteredTable = filtered.Length > 0 ? filtered.CopyToDataTable() : table.Clone();

// Create new workbook from modified data
WorkBook outputWorkbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet outputSheet = outputWorkbook.CreateWorkSheet("Processed Data");

// Import filtered DataTable back into Excel
outputSheet.LoadFromDataTable(filteredTable, true);

// Save the final XLSX file
outputWorkbook.SaveAs("processed-output.xlsx");
Imports IronXL
Imports System.Data

' Load CSV file into workbook
Dim sourceWorkbook As WorkBook = WorkBook.LoadCSV("input.csv", fileFormat:=ExcelFileFormat.XLSX, ListDelimiter:=",")

' Convert worksheet to DataTable for manipulation
Dim table As DataTable = sourceWorkbook.DefaultWorkSheet.ToDataTable(True)

' Filter rows -- keep only rows where the third column value is greater than 100
Dim filtered As DataRow() = table.Select("Column3 > 100")
Dim filteredTable As DataTable = If(filtered.Length > 0, filtered.CopyToDataTable(), table.Clone())

' Create new workbook from modified data
Dim outputWorkbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
Dim outputSheet As WorkSheet = outputWorkbook.CreateWorkSheet("Processed Data")

' Import filtered DataTable back into Excel
outputSheet.LoadFromDataTable(filteredTable, True)

' Save the final XLSX file
outputWorkbook.SaveAs("processed-output.xlsx")
$vbLabelText   $csharpLabel

Output

C# CSV to XLSX: A Complete Developer Guide: Image 4 - CSV to DataTable to XLSX output

The ToDataTable method exports worksheet data to a .NET DataTable, with the boolean parameter controlling whether the first row is treated as column headers. LoadFromDataTable imports the data back, writing column headers as the first row when the second parameter is true. This bidirectional conversion enables full use of LINQ and ADO.NET operations between CSV ingestion and Excel output. Review the IronXL DataTable documentation for additional options.

How Do You Save an XLSX File to a Stream Instead of a File Path?

Server-side applications often need to deliver Excel files directly to HTTP responses rather than writing temporary files to disk. IronXL supports saving workbooks to MemoryStream for this purpose.

using IronXL;
using System.IO;

// Load and convert CSV data
WorkBook workbook = WorkBook.LoadCSV("report-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

WorkSheet sheet = workbook.DefaultWorkSheet;

// Save workbook to a memory stream instead of a file
using MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream);

// Reset stream position for reading
stream.Position = 0;

// The stream is now ready to pass to an HTTP response, upload to cloud storage,
// or attach to an email. For ASP.NET Core:
// return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "report.xlsx");

// Write bytes to verify stream contains XLSX data
byte[] xlsxBytes = stream.ToArray();
Console.WriteLine($"Generated XLSX size: {xlsxBytes.Length} bytes");
using IronXL;
using System.IO;

// Load and convert CSV data
WorkBook workbook = WorkBook.LoadCSV("report-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

WorkSheet sheet = workbook.DefaultWorkSheet;

// Save workbook to a memory stream instead of a file
using MemoryStream stream = new MemoryStream();
workbook.SaveAs(stream);

// Reset stream position for reading
stream.Position = 0;

// The stream is now ready to pass to an HTTP response, upload to cloud storage,
// or attach to an email. For ASP.NET Core:
// return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "report.xlsx");

// Write bytes to verify stream contains XLSX data
byte[] xlsxBytes = stream.ToArray();
Console.WriteLine($"Generated XLSX size: {xlsxBytes.Length} bytes");
Imports IronXL
Imports System.IO

' Load and convert CSV data
Dim workbook As WorkBook = WorkBook.LoadCSV("report-data.csv", fileFormat:=ExcelFileFormat.XLSX, ListDelimiter:=",")

Dim sheet As WorkSheet = workbook.DefaultWorkSheet

' Save workbook to a memory stream instead of a file
Using stream As New MemoryStream()
    workbook.SaveAs(stream)

    ' Reset stream position for reading
    stream.Position = 0

    ' The stream is now ready to pass to an HTTP response, upload to cloud storage,
    ' or attach to an email. For ASP.NET Core:
    ' Return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "report.xlsx")

    ' Write bytes to verify stream contains XLSX data
    Dim xlsxBytes As Byte() = stream.ToArray()
    Console.WriteLine($"Generated XLSX size: {xlsxBytes.Length} bytes")
End Using
$vbLabelText   $csharpLabel

Saving to a stream avoids disk read/write operations and eliminates the need to clean up temporary files. This pattern is widely used in ASP.NET Core file download endpoints where the XLSX is generated on demand. The SaveAs(Stream) overload writes a complete, valid XLSX archive to any writable stream instance.

How Do You Work with Multiple Worksheets in a Converted Workbook?

A single XLSX workbook can contain multiple worksheets. After converting a CSV file, the workbook holds one sheet by default. Additional sheets can be created programmatically to organize related data.

using IronXL;

// Load primary CSV data
WorkBook workbook = WorkBook.LoadCSV("quarterly-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

// Rename the default sheet created from the CSV
WorkSheet q1Sheet = workbook.DefaultWorkSheet;
q1Sheet.Name = "Q1 Data";

// Create additional worksheets for summary information
WorkSheet summarySheet = workbook.CreateWorkSheet("Summary");

// Write summary headers and formulas
summarySheet["A1"].Value = "Total Records";
summarySheet["B1"].Formula = $"=COUNTA('{q1Sheet.Name}'!A:A)-1";

summarySheet["A2"].Value = "Data Sheet";
summarySheet["B2"].Value = q1Sheet.Name;

// Save the multi-sheet workbook
workbook.SaveAs("multi-sheet-report.xlsx");
using IronXL;

// Load primary CSV data
WorkBook workbook = WorkBook.LoadCSV("quarterly-data.csv",
    fileFormat: ExcelFileFormat.XLSX,
    ListDelimiter: ",");

// Rename the default sheet created from the CSV
WorkSheet q1Sheet = workbook.DefaultWorkSheet;
q1Sheet.Name = "Q1 Data";

// Create additional worksheets for summary information
WorkSheet summarySheet = workbook.CreateWorkSheet("Summary");

// Write summary headers and formulas
summarySheet["A1"].Value = "Total Records";
summarySheet["B1"].Formula = $"=COUNTA('{q1Sheet.Name}'!A:A)-1";

summarySheet["A2"].Value = "Data Sheet";
summarySheet["B2"].Value = q1Sheet.Name;

// Save the multi-sheet workbook
workbook.SaveAs("multi-sheet-report.xlsx");
Imports IronXL

' Load primary CSV data
Dim workbook As WorkBook = WorkBook.LoadCSV("quarterly-data.csv", fileFormat:=ExcelFileFormat.XLSX, ListDelimiter:=",")

' Rename the default sheet created from the CSV
Dim q1Sheet As WorkSheet = workbook.DefaultWorkSheet
q1Sheet.Name = "Q1 Data"

' Create additional worksheets for summary information
Dim summarySheet As WorkSheet = workbook.CreateWorkSheet("Summary")

' Write summary headers and formulas
summarySheet("A1").Value = "Total Records"
summarySheet("B1").Formula = $"=COUNTA('{q1Sheet.Name}'!A:A)-1"

summarySheet("A2").Value = "Data Sheet"
summarySheet("B2").Value = q1Sheet.Name

' Save the multi-sheet workbook
workbook.SaveAs("multi-sheet-report.xlsx")
$vbLabelText   $csharpLabel

The CreateWorkSheet method adds a new empty sheet to the workbook. Sheets are accessible by name or by index through workbook.WorkSheets. Cross-sheet formula references use the standard Excel notation 'SheetName'!CellRef. For more on multi-sheet operations, see the IronXL multiple worksheet guide.

What Are Your Next Steps?

Converting CSV files to XLSX in C# with IronXL takes just a few lines of code and produces a fully compliant Excel workbook without any Microsoft Office dependency. The examples above cover the complete workflow -- from basic CSV loading and saving to encoding handling, cell formatting, chart creation, DataTable integration, stream output, and multi-sheet workbooks.

Key capabilities covered in this guide:

  • Basic CSV to XLSX conversion with WorkBook.LoadCSV and SaveAs
  • Encoding specification for international character sets
  • Cell and range formatting applied after conversion
  • Chart creation embedded directly in the XLSX file
  • DataTable round-trip for filtered and transformed data
  • MemoryStream output for server-side file delivery
  • Multi-sheet workbook construction from a single CSV source

IronXL supports Windows, Linux, macOS, Docker, and Azure deployments across .NET Framework, .NET Core, and .NET 5 through 10. To explore more capabilities, review the IronXL documentation, browse the Excel API object reference, or check the IronXL how-to guides for topics like reading Excel files, merging cells, and applying formulas. Download a free trial to test all features in a development environment, or purchase a license for production deployment.

Get stated with IronXL now.
green arrow pointer

Frequently Asked Questions

How do you convert a CSV file to XLSX in C# without Microsoft Office?

Use IronXL's WorkBook.LoadCSV method to load the CSV file, then call workbook.SaveAs('output.xlsx') to write the XLSX file. IronXL does not require Microsoft Office or the Open XML SDK -- it reads and writes Excel files using its own parser.

What NuGet package is used to convert CSV to Excel in C#?

Install the IronXl NuGet package using 'Install-Package IronXl' in Visual Studio or 'dotnet add package IronXl' from the .NET CLI. The package targets .NET Framework 4.6.2+ and all .NET Core and .NET 5 through 10 runtimes.

How do you specify the delimiter when loading a CSV file with IronXL?

Pass the ListDelimiter parameter to WorkBook.LoadCSV, for example: WorkBook.LoadCSV('data.csv', fileFormat: ExcelFileFormat.XLSX, ListDelimiter: ',') for comma-separated files or ListDelimiter: ';' for semicolon-separated files.

Can IronXL handle CSV files with non-ASCII or international characters?

Yes. Pass a System.Text.Encoding instance to the encoding parameter of LoadCSV. IronXL automatically detects UTF-8 for most standard files. For Windows-1252, ISO-8859-1, or other encodings, specify the encoding explicitly to preserve international characters.

How do you add a chart to an Excel file generated from CSV data using IronXL?

After loading the CSV, call worksheet.CreateChart(ChartType.Column, top, left, bottom, right) to create a chart, then use chart.AddSeries to link cell ranges, and call chart.Plot() before saving. IronXL supports column, bar, line, area, and pie chart types.

How do you save a generated XLSX file to a MemoryStream for HTTP response in ASP.NET Core?

Call workbook.SaveAs(stream) where stream is a MemoryStream instance, then reset stream.Position to 0 before returning it. In an ASP.NET Core controller, return File(stream, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'report.xlsx').

Can IronXL convert CSV data to a DataTable before writing to Excel?

Yes. Load the CSV with LoadCSV, then call workbook.DefaultWorkSheet.ToDataTable(true) to export to a DataTable. After filtering or transforming the data, create a new workbook and call outputSheet.LoadFromDataTable(table, true) to import the modified data.

Does IronXL support multiple worksheets when converting from CSV?

Yes. After loading a CSV file, the workbook contains one default sheet. Call workbook.CreateWorkSheet('SheetName') to add additional sheets. Sheets can reference each other using standard Excel cross-sheet formula syntax.

What .NET versions and platforms does IronXL support?

IronXL supports .NET Framework 4.6.2 and later, .NET Core 3.1, and .NET 5 through .NET 10. It runs on Windows, Linux, macOS, Docker, and Azure, making it suitable for both desktop and server-side deployments.

How do you apply cell formatting like bold headers and number formats after CSV conversion?

After loading the CSV, access a Range with sheet['A1:Z1'] and set Style.Font.Bold = true, Style.SetBackgroundColor('#hex'), or Style.NumberFormat = '$#,##0.00'. IronXL exposes the full Excel styling API through the Style property on cells and ranges.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me