In this tutorial, we’ll concentrate on the detailed process for using one of the most popular document converter APIs to convert XLSX to JPG using C#. This article also includes instructions on how to set up the document conversion package and a sample code example to transform XLSX to JPG in C#. Here are the essential steps and sample code example for XLSX to JPG conversion.
Steps to Convert XLSX to JPG using C#
- Install GroupDocs.Conversion for .NET using the NuGet package manager
- Add a reference to GroupDocs.Conversion namespace for XLSX to JPG conversion
- Create an instance of Converter class by passing input XLSX file path
- Call the Converter.GetPossibleConversions method to get the conversion options
- Call the Convert.Save method to save output JPG at disk
You can easily export XLSX to JPG using C# by following the above steps and installing the conversion library on any machine. You simply need to load the input XLSX document and save the output JPG with conversion options. The platform independent library used in this example allows the following code example to execute on any system with .NET installed.
Code to Convert XLSX to JPG using C#
using GroupDocs.Conversion; | |
namespace ConvertXLSXtoJPGusingCSharp | |
{ | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
// Set License to avoid the limitations of Conversion library | |
License lic = new License(); | |
lic.SetLicense(@"GroupDocs.Conversion.lic"); | |
// Import XLSX document | |
var converter = new GroupDocs.Conversion.Converter("input.xlsx"); | |
// Get conversion option for JPG output | |
var convertOptions = converter.GetPossibleConversions()["jpg"] | |
.ConvertOptions; | |
// Save the JPG to disk | |
converter.Convert("ConvertXLSXtoJPGusingCSharp.jpg", convertOptions); | |
} | |
} | |
} |
We provided all guidelines above to complete the conversion process C# XLSX to JPG. Windows, macOS, and Linux are widely used operating systems where you can use the above instructions to convert any XLSX file to JPG format after installing .NET only. You may easily use the above code in your applications once the document conversion library has been set up properly and the paths of the documents have been modified as needed.
Previously, we released a topic on converting XLSX to HTML, and if you need further help, you can read our tutorial on how to convert XLSX to HTML using C#.