Excel spreadsheets offer a rich array of features for data organization and analysis, CSV (Comma-Separated Values) files provide a simple, standardized format for storing tabular data. Therefore, the ability to seamlessly convert Excel files to CSV format is essential for streamlining data processing workflows. Furthermore, the CSV files are ideal for interoperability across different platforms, applications, and programming languages. So in this article, we are going to explore the importance of this conversion and learn how to perform it effortlessly using .NET REST API.
This article is covering following topics:
- Excel Workbook to CSV Conversion API
- Convert Excel to CSV in C# .NET
- Convert XLSX to CSV using cURL commands
Excel Workbook to CSV Conversion API
GroupDocs.Conversion Cloud SDK for .NET offers a comprehensive set of features and functionalities designed to streamline the process of converting Excel files to CSV format. The SDK provides support for a wide range of input formats, including various versions of Excel files, ensuring compatibility with diverse data sources. It also offers extensive customization options, allowing you to specify conversion settings such as delimiter types, encoding formats, and output file structures according to their specific requirements.
The first step is the installation of SDK in our .NET solution. Therefore, search GroupDocs.Conversion-Cloud in NuGet package manager and click the Install button. Another option is to execute the following command in package manager console.
NuGet\Install-Package GroupDocs.Conversion-Cloud -Version 24.2.0
Once the REST API is successfully installed, make sure you have the API credentials(i.e. Client ID and Client Secret). You may visit this short tutorial explaining the details on how to get the API credentials.
Convert Excel to CSV in C# .NET
This section explains the details on converting Excel to CSV using C# .NET while ensuring high-quality conversion results, preserving data integrity and maintaining consistency throughout the process.
- Create an instance of
Configuration
class where we pass client credentials as arguments.
var configurations = new Configuration(clientId, clientSecret1);
- Initialize the
ConvertApi
where we pass Configuration object as an input argument.
var apiInstance = new ConvertApi(configurations);
- Upload the input Excel workbook to cloud storage.
fileUpload.UploadFile(new UploadFileRequest("input.xls", stream));
- Create an instance
ConvertSettings
where we specify the name for input XLS, resultant format ascsv
and the name for resultant CSV file as arguments.
var settings = new ConvertSettings{...}
- Call the ConvertDocumentRequest API to turn Excel to CSV format and save the resultant CSV to cloud storage.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
The sample Excel workbook and resultant CSV generated in the above example can be downloaded from input.xls and resultant.csv.
Convert XLSX to CSV using cURL commands
Converting Excel to CSV format using GroupDocs.Conversion Cloud and cURL commands offers a seamless and efficient solution for automating document conversion tasks. With cURL commands, you can easily initiate the conversion process, specify the input Excel file, and receive the resulting CSV output—all from the command line or within your scripts. This approach simplifies integration into existing workflows and automation pipelines, requiring only basic commands to manage the conversion process.
The first step in this approach is to obtain a personalized JWT access token. So, once you have a JWT token, please execute the following cURL command to convert XLSX to CSV format and save the resultant CSV in cloud storage.
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"StorageName\": \"internal\", \"FilePath\": \"{sourceFile}\", \"Format\": \"csv\",\"OutputPath\": \"{resultantFile}\"}"
Please replace sourceFile
with the name of input Excel workbook, resultantFile
with the name of resultant CSV and accessToken
with personalized JWT access token.
Try Free Excel to CSV Conversion App
We have developed a free online XLSX to CSV Converter based on GroupDocs.Conversion Cloud API. It is a lightweight, super-efficient solution, providing an opportunity to witness the amazing capabilities of our Cloud SDK for Excel workbook to CSV conversion.
Useful Links
Conclusion
In conclusion, whether you choose to utilize GroupDocs.Conversion Cloud with cURL commands or integrate GroupDocs.Conversion Cloud SDK for .NET, converting Excel to CSV becomes a seamless and efficient process. Both approaches offer versatile solutions for automating document conversion tasks, empowering users to effortlessly bridge the gap between Excel and CSV formats. Nevertheless, our Cloud SDK provides access to a wide range of features, extensive documentation, and reliable support, enabling you to customize the conversion process and ensure high-quality results.
Related Articles
We highly recommend visiting the following links to learn more about: