
Excel to JPEG Image in C# .NET.
Excel is a powerful tool for organizing and analyzing data but may not always be the most effective way to present information, especially when targeting broader audiences or incorporating data into presentations, reports, or websites. However, by converting Excel spreadsheets to JPG images, you can create visually appealing representations of data that is easier to incorporate into various media types. Furthermore, it enhances the overall aesthetic appeal of documents, and ensure compatibility across different platforms and devices.
- Excel to JPG Conversion SDK
- Convert Excel to JPEG using C# .NET
- Excel Worksheet to Image using cURL commands
Excel to JPG Conversion SDK
By leveraging the robust features and intuitive GroupDocs.Conversion Cloud SDK for .NET, you can easily initiate Excel to JPG conversions with just a few lines of code. The REST API ensures high-quality conversions, preserving the integrity and fidelity of the original Excel data while delivering crisp and visually appealing JPG images.
The first step is to install the SDK by searching 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
After the installation, please make sure you have obtained your personalized 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 JPEG using C# .NET
The following section explains the details on how we can streamline Excel (XLS, XLSX) to JPEG conversion using C# .NET.
- 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 the cloud storage.
fileUpload.UploadFile(new UploadFileRequest("input.xls", stream));
- Create an instance
ConvertSettings
where we specify the name for input XLS, resultant format asJPG
and the name for resultant JPG image as arguments.
var settings = new ConvertSettings{...}
- Call the ConvertDocumentRequest API to turn Excel to JPG and save the resultant JPEG image to the cloud storage.
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet | |
// Obtain your API credentials | |
string clientId = "4bdefca3-f08c-4088-9ca0-55c38f4b7f22"; | |
string clientSecret1 = "a43c8b4365246a062688a259abe5b469"; | |
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret. | |
var configurations = new GroupDocs.Conversion.Cloud.Sdk.Client.Configuration(clientId, clientSecret1); | |
// Define the value of ApiBaseUrl to set the base url of the Excel to JPG converter API. | |
configuration.ApiBaseUrl = "https://api.groupdocs.cloud"; | |
// Initialize an instance of the ConvertApi class with the object of the Configuration class. | |
var apiInstance = new GroupDocs.Conversion.Cloud.Sdk.Api.ConvertApi(configurations); | |
// load the input Excel workbook from local drive | |
using (var stream = System.IO.File.OpenRead("input.xls")) | |
{ | |
// create an instance of FileApi | |
var fileUpload = new FileApi(configurations); | |
// upload the input Excel workbook to cloud storage | |
fileUpload.UploadFile(new UploadFileRequest("input.xls", stream)); | |
// create ConvertSettings where we define the input Excel workbook and the name for resultant JPEG image | |
var settings = new ConvertSettings | |
{ | |
StorageName = "internal", | |
FilePath = "input.xls", | |
Format = "jpg", | |
OutputPath = "output.jpeg" | |
}; | |
// Invoke the ConvertDocument method for Excel to JPG image conversion online. | |
var response = apiInstance.ConvertDocument(new GroupDocs.Conversion.Cloud.Sdk.Model.Requests.ConvertDocumentRequest(settings)); | |
if (response != null && response.Equals("OK")) | |
{ | |
// print success message | |
Console.WriteLine("The Excel to JPEG conversion completed successfully !"); | |
} | |
} |
Excel Worksheet to Image using cURL commands
The combination of GroupDocs.Conversion Cloud and cURL commands provides users with a versatile, efficient, and reliable solution for converting Excel files to JPEG images, enabling seamless integration into various workflows and environments with minimal effort.
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 JPG format and save the resultant JPEG image to the 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\": \"jpg\", \"LoadOptions\": { \"Format\": \"xls\" }, \"OutputPath\": \"{resultantFile}\"}"
Please replace sourceFile
with the name of input Excel workbook, resultantFile
with the name of resultant JPG image and accessToken
with personalized JWT access token.
Free Excel to JPG Converter
You may take a quick look over free online XLSX to JSON Converter. This App is developed on top of GroupDocs.Conversion Cloud REST APIs. Please try using this lightweight, super-efficient solution and witness the amazing capabilities by converting Excel workbook to JPEG images.
Useful Links
Conclusion
In conclusion, whether you opt for the GroupDocs.Conversion Cloud SDK for .NET or leverage cURL commands with GroupDocs.Conversion Cloud, the conversion of Excel files to JPEG images has never been easier. Both approaches offer efficient and reliable solutions for seamlessly transforming Excel data into visually appealing JPEG format. Please try it out today and unlock new possibilities for transforming your Excel files into stunning JPEG images.
Related Articles
We highly recommend visiting the following links to learn more about: