- C#/VB.NET: Convert Excel to HTML
- Install Spire.XLS for .NET
- Convert Excel to HTML
- Convert Excel to HTML with Images Embedded
- Apply for a Temporary License
- See Also
- Convert XLSX to HTML in C#
- XLSX to HTML conversion with a few lines of .NET code
- GroupDocs.Conversion
- About GroupDocs.Conversion for .NET API
- Steps to convert XLSX to HTML in C#
- System Requirements
- XLSX to HTML Live Demo
- Other supported XLSX conversions in C#
- Effortless Excel to HTML Conversion using C# .NET
- Excel to Web Conversion API#
- View Spreadsheet Online using C##
- Excel to HTML Online using cURL Commands#
- Concluding Remarks#
- Related Articles#
- Convert XLSX to HTML in C#
- High-speed C# library for converting XLSX to HTML. This is a professional software solution to import and export XLSX, HTML, and many other formats on .NET Framework, .NET Core or Mono Platforms.
- Aspose.Cells for .NET
- Overview
- Convert XLSX to HTML Using C#
- Package Manager Console Command
- Save XLSX to HTML in C# Online for Free
C#/VB.NET: Convert Excel to HTML
When you create an Excel table and want to publish it online as a web page, the simplest way is to convert it to an HTML file. This article will demonstrate how to convert Excel to HTML programmatically from the following two aspects using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Convert Excel to HTML
Spire.XLS for .NET supports converting a specific Excel worksheet to HTML using Worksheet.SaveToHtml() method. Detailed steps are listed below.
- Create a Workbook instance.
- Load an Excel sample document using Workbook.LoadFromFile() method.
- Get a specific worksheet using Workbook.Worksheets[] property
- Save the worksheet as an HTML file using Worksheet.SaveToHtml() method.
using Spire.Xls; namespace XLSToHTML < class Program < static void Main(string[] args) < //Create a Workbook instance Workbook workbook = new Workbook(); //Load an Excel sample document workbook.LoadFromFile(@"sample.xlsx"); //Get the first worksheet of the document Worksheet sheet = workbook.Worksheets[0]; //Save the worksheet to HTML sheet.SaveToHtml("ExcelToHTML.html"); >> >
Imports Spire.Xls Namespace Xls2Html Class Program Private Shared Sub Main(args As String()) 'Create a Workbook instance Dim workbook As New Workbook() 'Load an Excel sample document workbook.LoadFromFile("sample.xlsx") 'Get the first worksheet of the document Dim sheet As Worksheet = workbook.Worksheets(0) 'Save the worksheet to HTML sheet.SaveToHtml("ExcelToHTML.html"); End Sub End Class End Namespace
Convert Excel to HTML with Images Embedded
The following are steps to convert an Excel worksheet to HTML with images embedded.
- Create a Workbook instance.
- Load an Excel sample document using Workbook.LoadFromFile() method.
- Get a specific worksheet using Workbook.Worksheets[] property.
- Create an HTMLOptions instance.
- Set the ImageEmbedded as true to embed images to HTML.
- Save the worksheet as an HTML file using Worksheet.SaveToHtml() method.
using Spire.Xls; using Spire.Xls.Core.Spreadsheet; namespace XLSToHTML < class Program < static void Main(string[] args) < //Create a Workbook instance Workbook workbook = new Workbook(); //Load an Excel sample document workbook.LoadFromFile(@"sample.xlsx"); //Get the first worksheet of the document Worksheet sheet = workbook.Worksheets[0]; //Create an HTMLOptions instance HTMLOptions options = new HTMLOptions(); //Embed images to HTML options.ImageEmbedded = true; //Save the worksheet to HTML sheet.SaveToHtml("XLS2HTML.html", options); >> >
Imports Spire.Xls Imports Spire.Xls.Core.Spreadsheet Namespace Xls2Html Class Program Private Shared Sub Main(args As String()) 'Create a Workbook instance Dim workbook As New Workbook() 'Load an Excel sample document workbook.LoadFromFile("sample.xlsx") 'Get the first worksheet of the document Dim sheet As Worksheet = workbook.Worksheets(0) 'Create an HTMLOptions instance Dim options As New HTMLOptions() 'Embed images to HTML options.ImageEmbedded = True 'Save the worksheet to HTML sheet.SaveToHtml("XLS2HTML.html", options); End Sub End Class
Apply for a Temporary License
If you’d like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
See Also
Convert XLSX to HTML in C#
XLSX to HTML conversion with a few lines of .NET code
GroupDocs.Conversion
About GroupDocs.Conversion for .NET API
GroupDocs.Conversion for .NET can be used to convert Microsoft Word, Excel, PowerPoint, PDF, Visio and other formats. GroupDocs.Conversion is a standalone API that is suitable for back-end and internal systems where high performance is required. It does not depend on any software such as Microsoft or Open Office.
Convert your XLSX files to HTML in .NET easily. You can use just a couple of C# code lines in any platform of your choice like — Windows, Linux, macOS. You can try XLSX to HTML conversion for free and evaluate conversion results quality. Along with simple file conversion scenarios you can try more advanced options for loading source XLSX file and for saving output HTML result.
For example, for the source XLSX file you may use the following load options:
- auto-detect file format;
- specify password for protected files (if file format supports it);
- replace missing fonts to preserve document appearance.
There are also advanced convert options for the HTML file:
- convert specific document page or page range;
- add a watermark to the converted HTML file and many more.
Once conversion is completed you can save your HTML file to the local file path or any third-party storage like FTP, Amazon S3, Google Drive, Dropbox etc. Please note — to convert XLSX to HTML there is no need for any additional software installed — like MS Office, Open Office, Adobe Acrobat Reader etc.
Steps to convert XLSX to HTML in C#
GroupDocs.Conversion for .NET makes it easy for developers to convert a XLSX file to HTML with a few lines of code.
- Create an instance of the Converter class and provide the file XLSX with the full path
- Create and set ConvertOptions for HTML type.
- Call the Converter.Convert method and pass the full path and format (HTML) as a parameter
System Requirements
Basic conversion with GroupDocs.Conversion for .NET can be done in just a few simple steps. Our APIs are supported on all major platforms and operating systems. Before executing the code below, make sure you have the following prerequisites installed on your system.
- Operating systems: Microsoft Windows, Linux, MacOS
- Development environments: Microsoft Visual Studio, Xamarin, MonoDevelop
- Frameworks: .NET Framework, .NET Standard, .NET Core, Mono
- Get the latest GroupDocs.Conversion for .NET from Nuget
// Load source file XLSX for conversion var converter = new GroupDocs.Conversion.Converter("input.xlsx"); // Prepare conversion options for target format HTML var convertOptions = converter.GetPossibleConversions()["html"].ConvertOptions; // Convert to HTML format converter.Convert("output.html", convertOptions);
XLSX to HTML Live Demo
Convert XLSX to HTML now by visiting the GroupDocs.Conversion App website. Online demo has the following advantages
No need to write any code
Just upload the source file
Get download link to save the file
Other supported XLSX conversions in C#
You can also convert XLSX to many other file formats. Please see the list below.
(OpenDocument Flat XML Spreadsheet)
(Hypertext Markup Language File)
(Hyper Text Markup Language)
(JavaScript Object Notation File)
(StarOffice Calc Spreadsheet)
(Microsoft Excel Spreadsheet (Legacy))
(Excel Macro-Enabled Template)
Effortless Excel to HTML Conversion using C# .NET
Excel spreadsheets are widely used for data storage and analysis, but they can be difficult to access and view online. The solution to this problem is to convert Excel spreadsheets to HTML tables, which are easily accessible and viewable on the web. With Aspose.Cells Cloud, this process has become even easier and more efficient. In this article, we will discuss how to use Aspose.Cells Cloud to convert Excel spreadsheets to HTML tables, and explore the other benefits of using this solution for your conversion requirements. Whether you are a developer or an end-user, this article is designed to provide you with the information you need to get started with Excel to HTML conversion.
Excel to Web Conversion API#
Enjoy seamless integration, advanced features and fast conversion capabilities of Aspose.Cells Cloud. It’s a cloud-based API that provides a simple and efficient solution for converting Excel spreadsheets to HTML tables. Convert XLS and XLSX to HTML tables with just a few lines of code, eliminating all the need for manual data entry and freeing up your time for more important tasks. So, whether you need to publish data online, share it with your team, or automate your workflow, Aspose.Cells Cloud provides a flexible and scalable solution for your Excel to HTML conversion needs.
Now, as per the scope of this article, we need to add Aspose.Cells Cloud SDK for .NET reference as a NuGet package in our C# .NET solution. Search “Aspose.Cells-Cloud” in NuGet package manager and add the package.
Furthermore, in order to use the API capabilities, we also need to have a Cloud dashboard account. If you are not already subscribed, please create a free account over Cloud Dashboard using valid email address and obtain your personalized client credentials.
View Spreadsheet Online using C##
Let’s discuss the steps on how online spreadsheet feature can be accomplished using C# .NET.
Use the following link to download the sample Excel worksheet (myDocument.xlsx) used in the above example.
Let’s understand the above code snippet:
CellsApi instance = new CellsApi(clientID, clientSecret);
Create an object of CellsApi where we pass the client credentials as arguments.
var file = System.IO.File.OpenRead(name)
Read the input Excel worksheet using OpenRead(…) method of the System.IO.File class.
instance.CellsWorkbookPutConvertWorkbook(file, format: format, outPath: resultantFile);
This method triggers the Excel to HTML conversion operation and saves the resultant HTML in Cloud storage.
Excel to HTML Online using cURL Commands#
Excel to HTML conversion can be achieved using cURL commands, which allow you to interact with Aspose.Cells Cloud API and perform various operations, including Excel to HTML conversion. Here’s a simple example of how to convert an Excel spreadsheet to HTML using cURL commands:
- Upload your Excel spreadsheet to a cloud storage platform, such as Google Drive or Dropbox.
- Obtain an API key from Aspose.Cells Cloud, which will be used to authenticate your API requests.
- Generate JWT access token based on client credentials using the following command.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
curl -v -X GET "https://api.aspose.cloud/v3.0/cells/myDocument(1).xlsx?format=HTML&isAutoFit=true&onlySaveTable=false&outPath=resultant.html&checkExcelRestriction=true" \ -H "accept: application/json" \ -H "authorization: Bearer "
- Once the cURL command is executed, the resultant HTML is saved to cloud storage.
- Now, instead of cloud storage, if we need to save the HTML to local drive, please try using the following cURL command:
curl -v -X GET "https://api.aspose.cloud/v3.0/cells/myDocument(1).xlsx?format=HTML&isAutoFit=true&onlySaveTable=false&checkExcelRestriction=false" \ -H "accept: application/json" \ -H "authorization: Bearer " \ -o "resultant.html"
Concluding Remarks#
In conclusion, converting Excel spreadsheets to HTML tables is a common task for many businesses and organizations, and Aspose.Cells Cloud provides a powerful and flexible solution for their needs. By using Aspose.Cells Cloud SDK for .NET, you can convert Excel spreadsheets to HTML tables quickly and easily, with just a few lines of code. Additionally, Aspose.Cells Cloud offers a range of features, including support for multiple programming languages, integration with popular cloud storage platforms, and a user-friendly interface, making it an ideal solution for businesses and organizations of all sizes. Whether you need to publish data online, share it with your team, or automate your workflow, Aspose.Cells Cloud provides a reliable and scalable solution for your Excel to HTML conversion needs.
We also recommend exploring the Product Documentation, as it contains a collection of topics explaining other exciting features of the API. Lastly, if you encounter any issues while using the API, please feel free to contact us via the free Product Support Forum.
Related Articles#
Please visit the following links to learn more about:
Convert XLSX to HTML in C#
High-speed C# library for converting XLSX to HTML. This is a professional software solution to import and export XLSX, HTML, and many other formats on .NET Framework, .NET Core or Mono Platforms.
Aspose.Cells for .NET
Overview
Download from NuGet
Open NuGet package manager, search for and install.
You may also use the following command from the Package Manager Console.
Convert XLSX to HTML Using C#
How do I convert XLSX to HTML? With Aspose.Cells for .NET library, you can easily convert XLSX to HTML programmatically with a few lines of code. Aspose.Cells for .NET is capable of building cross-platform applications with the ability to generate, modify, convert, render and print all Excel files. .NET Excel API not only convert between spreadsheet formats, it can also render Excel files as images, PDF, HTML, ODS, CSV, SVG, JSON, WORD, PPT and more, thus making it a perfect choice to exchange documents in industry-standard formats. Open NuGet package manager, search for Aspose.Cells and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Cells
Save XLSX to HTML in C# Online for Free
The following example demonstrates how to convert XLSX to HTML in C#.
Follow the easy steps to convert XLSX to HTML. Upload your XLSX file, then simply save it as HTML file. For both XLSX reading and HTML writing you can use fully qualified filenames. The output HTML content and formatting will be identical to the original XLSX document.