Rendering XML SpreadSheetML
Introduction
Welcome to the world of GroupDocs.Viewer for .NET! In this tutorial, we will guide you through rendering XML SpreadSheetML files with ease using GroupDocs.Viewer, a powerful .NET library. Whether you are a seasoned developer or just starting, this step-by-step guide will help you effortlessly integrate XML SpreadSheetML rendering into your applications.
Prerequisites
Before diving into the tutorial, make sure you have the following prerequisites set up:
- A development environment with .NET support.
- GroupDocs.Viewer for .NET library installed. You can download it here.
- A basic understanding of C# programming.
Import Namespaces
Begin by importing the necessary namespaces into your C# project. This ensures that you have access to the functionalities provided by GroupDocs.Viewer.
using GroupDocs.Viewer.Options;
using System;
using System.IO;
Step 1: Set Up Your Document Directory
Define the path to your documents directory where the output will be saved.
string outputDirectory = "Your Document Directory";
Step 2: Specify Output File Paths
Set up the full paths for the HTML, JPG, PNG, and PDF output files.
string pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.html");
Step 3: Specify Load Options
Explicitly specify the file type as Excel 2003 XML SpreadSheetML to render it accurately.
LoadOptions loadOptions = new LoadOptions(FileType.Excel2003XML);
Step 4: Render to Multi-Page HTML
Utilize the HTML view options to render the XML SpreadSheetML file into a multi-page HTML document.
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions))
{
HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFileFullPath);
viewer.View(options);
}
Step 5: Render to JPG
Render the XML SpreadSheetML file into a JPG image using the specified options.
pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.jpg");
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions))
{
JpgViewOptions options = new JpgViewOptions(pageFileFullPath);
viewer.View(options);
}
Step 6: Render to PNG
Similarly, render the file into a PNG image with the specified options.
pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.png");
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions))
{
PngViewOptions options = new PngViewOptions(pageFileFullPath);
viewer.View(options);
}
Step 7: Render to PDF
Finally, render the XML SpreadSheetML file into a PDF document using the specified options.
pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.pdf");
using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions))
{
PdfViewOptions options = new PdfViewOptions(pageFileFullPath);
viewer.View(options);
}
Conclusion
Congratulations! You have successfully learned how to render XML SpreadSheetML files using GroupDocs.Viewer for .NET. Enhance your document viewing capabilities by exploring more features and options provided by this versatile library.
FAQs
Is GroupDocs.Viewer compatible with other file formats?
Yes, GroupDocs.Viewer supports a wide range of document formats, including PDF, Word, Excel, and more.
Can I customize the appearance of the rendered documents?
Absolutely! GroupDocs.Viewer offers various customization options, allowing you to tailor the output to your specific needs.
Where can I find additional support and resources?
Visit the GroupDocs.Viewer forum for community support and explore the documentation for detailed information.
Is there a free trial available?
Yes, you can access the free trial here.
How do I obtain a temporary license?
You can get a temporary license here.