txt to excel

How to convert TXT to Excel workbook with .NET Cloud SDK.

In today’s data-driven landscape, the seamless conversion of plain text (TXT) files to Excel format stands as a critical necessity. Converting TXT to Excel is not merely a matter of convenience; it is an essential step towards unlocking the full potential of data. Because, the Excel’s structured and tabular format provides a robust framework for comprehending and visualizing information, enabling businesses to derive meaningful insights and make informed decisions. In this article, we delve into the significance of this conversion process and explore the simple and seamless approach for converting Text file to Excel workbook using .NET REST API.

TXT to Excel Conversion API

The conversion of TXT to Excel is made effortlessly dynamic with the help of Aspose.Cells Cloud SDK for .NET. This powerful tool not only streamlines the conversion process but also ensures an accurate migration from plain text to Excel format. It also enables you to manipulate worksheets, apply advanced formatting, and even generate charts seamlessly. Furthermore, owing to its cloud-based architecture, you can benefit from scalable and reliable performance without the need for complex local installations.

The first is to 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.

Conversion of Text File to Excel in C# .NET

Let’s embark on a journey to not just convert TXT to Excel, but to elevate the data processing capabilities using feature-rich Aspose.Cells Cloud SDK for .NET.

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

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

 cellsInstance.UploadFile("input.xls", inputFile);

Read input Text file and upload it to the cloud storage.

var response = cellsInstance.CellsWorkbookGetWorkbook("input.txt", null, format: "XLSX", isAutoFit: true, null, null, null, "output.xlsx", null);

Now, call the API to perform the Excel to CSV conversion online. After successful operation, the resultant CSV is also uploaded to the cloud storage.

txt to excel preview

A preview of TXT to Excel conversion using .NET REST API.

The input TXT file and the resultant Excel workbook produced in the above example can be downloaded from:

Convert TXT to Excel Workbook using cURL Commands

Transforming plain text (TXT) files into Excel format becomes an intuitive and powerful process with Aspose.Cells Cloud and cURL commands. So, by using the cURL commands, you can easily interact with Aspose.Cells Cloud API, where we specify the input TXT file and the desired output format. This cloud-based approach not only simplifies the conversion process but also ensures scalability and accessibility without the need for intricate local setups.

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"

Now, execute the following command to convert Text file to Excel online. This command expects the input TXT file to be already available in the cloud storage and after the conversion, the resultant Excel workbook is also stored in the cloud storage.

curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=XLSX&isAutoFit=true&onlySaveTable=true&outPath={Resultant}&checkExcelRestriction=true" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}"

Replace sourceFile with the name of input TXT file, Resultant with the name of resultant Excel workbook and accessToken with a JWT access token generated above.

  • In order to save the resultant Excel to be stored on local drive, please use the following cURL command, where we have skipped the resultant file name and have used -o argument to specify the resultant path.
curl -v "https://api.aspose.cloud/v3.0/cells/input.txt?format=XLSX&isAutoFit=true&onlySaveTable=true&checkExcelRestriction=true" \
-X GET \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-o "resultant.xlsx"

Conclusion

In conclusion, the two approaches for converting plain text (TXT) files to Excel emerge as contenders: utilizing local resources with .NET REST API and harnessing the power of the cloud with Aspose.Cells Cloud and cURL commands. Also, with the support for advanced Excel manipulations, formulas, and dynamic data features, the Aspose.Cells Cloud API becomes a one-stop solution for developers seeking not only seamless conversions but also a gateway to elevated data processing capabilities. Furthermore, the scalability, ease of integration, and feature-rich nature of Aspose.Cells Cloud make a compelling case for choosing it as the go-to tool, ensuring you can effortlessly convert TXT to Excel online.

We highly recommend visiting the following blogs: