Official help document: https://www.e-iceblue.cn/spirexls/spire-xls-for-net-program-guide-content.html
Spire.XLS for .NET is a professional .NET Excel component that can be used in various .NET frameworks, including ASP.NET and Windows Forms and other related .NET applications. Spire.XLS for .NET provides an object model Excel API that enables developers to quickly complete various programming operations on Excel on the .NET platform, such as creating new Excel documents based on templates, editing existing Excel documents, and editing Excel documents. Excel documents for conversion.
Spire.XLS for .NET is a standalone Excel component that does not depend on Microsoft Office Excel. It supports both older versions of Excel 97-2003 (.xls) format documents and newer versions of Excel 2007, Excel 2010, Excel 2013, Excel 2016 (.xlsx, .xlsb, .xlsm) and Open Office (.ods) format documents. Compared with developing your own Excel program or using Microsoft Automation, it has the advantages of high speed and reliability.
First install the Spire.XLS library
Install Spire.XLS using NuGet, after successful installation:
Code behind to add a reference:
using Spire.Xls;
Test 1: Convert Excel file to xml file
static void xlsx_to_xml()
{
//Create an object of the Workbook class
Workbook workbook = new Workbook();
//Load Excel document
workbook.LoadFromFile(“test.xlsx”);
//save as XML
workbook.SaveAsXml(“result.xml”);
}
Test 2: Convert Xml file to Excel file
static void xml_to_xlsx()
{
//Create an object of the Workbook class
Workbook workbook = new Workbook();
//load XML file
workbook.LoadFromXml(“result.xml”);
//Save as Excel document
workbook.SaveToFile(“ToExcel.xlsx”, FileFormat.Version2013);
}
The test verified that the conversion was successful, the only problem is that the free version has a limit of 5 sheets per workbook and 200 rows per sheet. This limit is enforced during reading or writing of XLS or PDF files. As of Free Spire.XLS v7.8, there are no restrictions on loading and saving .xlsx file formats. When converting Excel files to other formats, such as PDF/XPS/Images, only the first 3 pages of PDF/XPS/Images are available. An upgrade to Spire.XLS Business is required to lift the restriction. If there are not many pages in the workbook when using the scene, and the number of rows per page is small, you can directly use the free version. Of course, the conditions allow to purchase the commercial version, isn't it better to lift the restrictions.