excel to image

How to convert Excel worksheet to image with .NET Cloud SDK.

The need to seamlessly convert Excel spreadsheets into vibrant JPG images has become more apparent than ever. Also, in today’s digital landscape, the ability to effortlessly transform Excel data into visually appealing JPG images is invaluable. This article delves into the profound significance of this conversion, unveiling the diverse scenarios where it proves indispensable and empowers the users to add a dynamic visual dimension to their data presentations. Let’s explore the details on how we can make the information visually engaging and impactful using .NET REST API.

REST API for Excel to Picture Conversion

Transforming Excel spreadsheets into JPG images becomes a seamless and efficient process with the robust capabilities of Aspose.Cells Cloud SDK for .NET. This powerful SDK empowers you to integrate comprehensive Excel manipulation features directly into your applications, providing a reliable solution for Excel to JPG conversion. The SDK offers a wealth of amazing capabilities including extraction of data, manipulation of worksheets, and generation of dynamic charts—all in a cloud-based environment.

Now, we need 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.

Convert Excel to JPG in C# .NET

Let’s dive into the details where innovation meets efficiency, unlocking a spectrum of possibilities for dynamic and visually enriched data presentations. So, please follow the instructions given below to convert an XLS to JPG in C# .NET.

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

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

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

Upload the input Excel workbook to cloud storage.

SaveOptions saveOptions = new SaveOptions() { SaveFormat = "JPG", EnableHTTPCompression = true };

Create an instance of SaveOptions class where we define the resultant format as JPG.

var response = cellsInstance.CellsSaveAsPostDocumentSaveAs("sourceFile.xls", saveOptions, newfilename: "Converted.jpg", isAutoFitRows: true, isAutoFitColumns: true);

Call the API to initiate the Excel to JPG conversion operation. After successful operation, the resultant image is stored in cloud storage.

excel to image

A preview of Excel to JPG conversion using .NET Cloud SDK.

The input Excel workbook and the resultant JPG image generated in above example can be downloaded from:

XLS to JPG using cURL Commands

The conversion of XLS to JPG can also be accomplished using Aspose.Cells Cloud and cURL commands. This process becomes not only accessible but also highly adaptable. Whether you’re a developer integrating this feature into an application or an end user seeking a straightforward solution, Aspose.Cells Cloud and cURL commands offer a versatile approach to transform Excel data into visually compelling JPG images.

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 the JWT token, please execute the following command to initiate the Excel to picture conversion operation. The following request expects the input Excel file to be already available in the cloud storage. Once the command is executed successfully, the resultant JPG image is stored in cloud storage.

curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}/SaveAs?newfilename={outputFile}&isAutoFitRows=true&isAutoFitColumns=true&checkExcelRestriction=false&pageWideFitOnPerSheet=true&pageTallFitOnPerSheet=true" \
-X POST \
-H  "accept: application/json" \
-H  "authorization: Bearer {accessToken}" \
-H  "Content-Type: application/json" \
-d "{  \"SaveFormat\": \"JPG\",  \"EnableHTTPCompression\": true,}" \

Replace sourceFile with the name of input Excel workbook available in cloud storage, outputFile with the name of resultant JPG to be generated andaccessToken with a JWT access token generated above.

Conclusion

In conclusion, whether you opt for the streamlined capabilities of Aspose.Cells Cloud SDK for .NET or the scriptable efficiency of cURL commands, the Excel to JPG conversion journey is marked by accessibility, precision, and adaptability. So, whether you’re a developer seeking a robust SDK or an everyday user relying on straightforward command-line interactions, the combined power of these approaches ensures a dynamic and visually enriching experience for all.

We highly recommend visiting the following blogs: