csv to xlsx

How to convert CSV to Excel (XLSX, XLSX) using .NET REST API.

In the intricate tapestry of data management, the need for converting CSV to Excel workbook (XLSX, XLS) emerges as a pivotal step. It offers a gateway to a more dynamic and accessible data experience. Albeit the CSV files provide simplicity, but it lacks the robust functionalities and visual appeal of Excel. In this article, we unravel the compelling needs for converting CSV to Excel. So let’s delve into the details to bridge the gap between raw data and actionable insights using .NET REST API, ensuring a more streamlined and impactful data transformation experience.

.NET Cloud SDK for CSV to Excel Conversion

Aspose.Cells Cloud SDK for .NET provides a seamless transition from CSV to Excel (XLSX, XLS). This powerful SDK not only simplifies and accelerates the conversion process but also opens doors to a myriad of other capabilities. Some of the operations include (but not limited to) Excel worksheet manipulation, charts creation, advanced formatting, and even you can perform complex calculations.

Now search Aspose.Cells-Cloud in NuGet packages manager and click the Add Package button. Secondly, obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert CSV File to Excel in C#

Embark on a seamless journey for CSV to Excel (XLSX, XLS) conversion using C# .NET.

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

Create an object of CellsApi class where we pass client credentials as arguments.

PostWorkbookSaveAsRequest postworkbookSaveAsRequest = new PostWorkbookSaveAsRequest()

Create an instance of WorkbookSaveAsRequest where we provide the name of input CSV file, resultant XLS name and few optional parameters.

var response = cellsInstance.PostWorkbookSaveAs(postworkbookSaveAsRequest);

Call the API to initiate CSV to XLSX conversion operation. Once the code is successfully executed, the resultant Excel is stored in cloud storage.

csv to xls

CSV file to XLS conversion preview.

CSV to XLS Conversion using cURL Commands

The conversion of CSV to Excel using Aspose.Cells Cloud via cURL commands presents a swift and accessible pathway. This approach provides simplicity and ease of use, and introduces a gateway to a spectrum of additional capabilities.

The first step in this approach is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=921363a8-b195-426c-85f7-7d458b112383&client_secret=2bf81fca2f3ca1790e405c904b94d233" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Once we have a JWT token, please execute the following command to convert CSV to XLS format. After the conversion, the resultant Excel workbook is stored on cloud storage.

curl -v "https://api.aspose.cloud/v3.0/cells/{inputFile}/SaveAs?newfilename={resultantFile}&isAutoFitRows=true&isAutoFitColumns=true&checkExcelRestriction=false" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"SaveFormat\": \"XLS\",  \"ClearData\": true,  \"CreateDirectory\": true,  \"EnableHTTPCompression\": true,  \"RefreshChartCache\": true,  \"SortNames\": true,  \"ValidateMergedAreas\": true}"

Replace inputFile with the name of input CSV file available in Cloud storage, resultantFile with the name of output Excel worksheet to be generated and accessToken with JWT access token generated above.

Conclusion

In conclusion, the journey from CSV to Excel (XLSX, XLS) has been a testament to the versatile solutions provided by Aspose.Cells Cloud. Whether through the user-friendly Aspose.Cells Cloud SDK for .NET or the swift efficiency of cURL commands, you can experience the transformative power of data conversion. Whether you’re a developer crafting sophisticated applications or a command-line enthusiast seeking quick solutions, Aspose.Cells Cloud stands as a reliable companion, making the entire data processing workflow more efficient and feature-rich.

Frequently Asked Questions

  • How to perform CSV to Excel conversion for free ? We have developed a free CSV to Excel converter App which shows the capabilities of this powerful SDK. So try using it for free to explore the exciting capabilities of this SDK.

  • How can I get a free trial ? Once you are subscribed to Cloud dashboard, you are entitled to 150 free API calls per month to evaluate our RESTFul APIs. For further information, please visit Free Trial.

  • What is licensing cost for this API ? You can perform document conversion with as low as $0.025 / API call. For further details, please visit the Pricing Guide.

We highly recommend visiting the following blogs: