How to Convert XLSX to CSV using C# in .NET Framework

Spreadsheet software like Excel provides a simple and user-friendly way to organize and store data strings in a way that can be instantly sorted or parsed. However, the formatting and design of Excel spreadsheets may not always be compatible with different database software. In these cases, it is smart to transfer your data strings to CSV so that the database can quickly and easily analyze the plain text input. This API will show you how to convert any XLSX file to CSV, as well as how to convert multiple spreadsheets at once.

Image for post
Image for post

First, we need to install our SDK. This first code block will remain the same for both functions:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 1.3.4

Then, for our first function, we can call ConvertDocumentXlsxToCsv. This will only convert the first worksheet in your XLSX file:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;

The second function, though, will allow you to convert multiple Excel worksheets to separate CSV files at once. To perform this action, call our function, ConvertDocumentXlsxToCsvMulti:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;
using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;

Now, you can instantly convert any XSLX file to CSV for streamlined use in any non-Excel-compatible application. To retrieve your free API Key, visit the Cloudmersive website. This will give you access to 800 monthly calls across our library of APIs.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store