User Guide EasyXLS Basics Convert files Convert XML file to Excel XLSX, XLSB or XLS

Convert XML file to Excel XLSX, XLSB or XLS

Concept EasyXLS™ library allows you to import data from XML file to Excel.



EasyXLS can be successfully used inclusively to convert large XML files to Excel, XML files with big volume of data with fast conversion time.



The Excel library allows converting any XML to Excel, but for the best result, a schema similar with



EasyXLS also allows converting XML Spreadsheet file to Excel XLSX, XLSB or XLS file format.



The conversion is made in two steps. First, the XML file is imported and after that, the data is exported to Excel file. Once the XML was loaded in memory, optionally, the user can process data, add more features (like formulas, cell formatting, comments, hyperlinks, images, data validations, page setup, charts, so on) and save the file back in any Excel format like XLSX, XLSB or XLS file format. EasyXLS permits you to convert XML to Excel file without Excel installed, without Interop or any other additional software installed.The Excel library allows converting any XML to Excel, but for the best result, a schema similar with EasyXLS.xsd should be used. It is preferable to contain data in a table format simulating the rows and columns, like in the mentioned schema or like an HTML table and CDATA tag should mention EasyXLS word. The tags like table, row and data can be named differently, but the table alike format is important.EasyXLS also allows converting XML Spreadsheet file to Excel XLSX, XLSB or XLS file format.The conversion is made in two steps. First, the XML file is imported and after that, the data is exported to Excel file. Once the XML was loaded in memory, optionally, the user can process data, add more features (like formulas, cell formatting, comments, hyperlinks, images, data validations, page setup, charts, so on) and save the file back in any Excel format like XLSX, XLSB or XLS file format. Concept in action The below example is a common code about how to convert XML string to Excel.

Source code sample C#.NET VB.NET C++.NET J#.NET Java PHP ASP C++ VB6 VBS Coldfusion // Create an instance of the class that exports Excel files, having one sheet ExcelDocument workbook = new ExcelDocument(1); // Build XML string String xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" + "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" + "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" + "</Table>"; // Import data from an XML string into worksheet starting with A1 cell ExcelWorksheet xlsWorksheet = (ExcelWorksheet) workbook.easy_getSheetAt(0); xlsWorksheet.easy_insertXMLFromString(xml, "A1"); // Export Excel file workbook.easy_WriteXLSXFile("C:\\Samples\\XML to Excel.xlsx"); ' Create an instance of the class that exports Excel files, having one sheet Dim workbook As New ExcelDocument(1) ' Build XML string Dim Xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" & vbCrLf & _ "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" & vbCrLf & _ "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" & vbCrLf & _ "</Table>" ' Import data from an XML string into worksheet starting with A1 cell Dim xlsWorksheet As ExcelWorksheet = workbook.easy_getSheetAt(0) xlsWorksheet.easy_insertXMLFromString(Xml, "A1") ' Export Excel file workbook.easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx") // Create an instance of the class that exports Excel files, having one sheet ExcelDocument ^workbook = gcnew ExcelDocument(1); // Build XML string String ^xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" "</Table>"; // Import data from an XML string into worksheet starting with A1 cell ExcelWorksheet ^xlsWorksheet = safe_cast<ExcelWorksheet^>(workbook->easy_getSheetAt(0)); xlsWorksheet->easy_insertXMLFromString(xml, "A1"); // Export Excel file workbook->easy_WriteXLSXFile("C:\\Samples\\XML to Excel.xlsx"); // Create an instance of the class that exports Excel files, having one sheet ExcelDocument workbook = new ExcelDocument(1); // Build XML string String xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" + "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" + "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" + "</Table>"; // Import data from an XML string into worksheet starting with A1 cell ExcelWorksheet xlsWorksheet = (ExcelWorksheet) workbook.easy_getSheetAt(0); xlsWorksheet.easy_insertXMLFromString(xml, "A1"); // Export Excel file workbook.easy_WriteXLSXFile("C:\\Samples\\XML to Excel.xlsx"); // Create an instance of the class that exports Excel files, having one sheet ExcelDocument workbook = new ExcelDocument(1); // Build XML string String xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" + "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" + "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" + "</Table>"; // Import data from an XML string into worksheet starting with A1 cell ExcelWorksheet xlsWorksheet = (ExcelWorksheet) workbook.easy_getSheetAt(0); xlsWorksheet.easy_insertXMLFromString(xml, "A1"); // Export Excel file workbook.easy_WriteXLSXFile("C:\\Samples\\XML to Excel.xlsx"); // Create an instance of the class that exports Excel files $workbook = new COM("EasyXLS.ExcelDocument"); // Create one sheet $workbook->easy_addWorksheet_2("Sheet1"); // Build XML string $xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" . "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" . "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" . "</Table>"; // Import data from an XML string into worksheet starting with A1 cell $xlsWorksheet = $workbook->easy_getSheetAt(0); $xlsWorksheet->easy_insertXMLFromString_3($xml, "A1"); // Export Excel file $workbook->easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx");

' Create an instance of the class that exports Excel files set workbook = Server.CreateObject("EasyXLS.ExcelDocument") ' Create one sheet workbook.easy_addWorksheet_2("Sheet1") ' Build XML string Dim xml: xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" & _ vbNewline & "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" & _ vbNewline & "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" & _ vbNewline & "</Table>" ' Import data from an XML string into worksheet starting with A1 cell set xlsWorksheet = workbook.easy_getSheetAt(0) xlsWorksheet.easy_insertXMLFromString_3 xml, "A1" ' Export Excel file workbook.easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx")

// Create an instance of the class that exports Excel files EasyXLS::IExcelDocumentPtr workbook; hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument), NULL, CLSCTX_ALL, __uuidof(EasyXLS::IExcelDocument), (void**) &workbook) ; // Create one sheet workbook->easy_addWorksheet_2("Sheet1"); // Build XML string char* xml = (char*)malloc(536*sizeof(char)); strcpy(xml, "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>"); strcat(xml, "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>"); strcat(xml, "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>"); strcat(xml, "</Table>"); // Import data from an XML string into worksheet starting with A1 cell EasyXLS::IExcelWorksheetPtr xlsWorksheet = (EasyXLS::IExcelWorksheetPtr)workbook->easy_getSheetAt(0); xlsWorksheet->easy_insertXMLFromString_3(xml, "A1"); // Export Excel file workbook->easy_WriteXLSXFile("C:\\Samples\\XML to Excel.xlsx");

' Create an instance of the class that exports Excel files Set workbook = CreateObject("EasyXLS.ExcelDocument") ' Create one sheet workbook.easy_addWorksheet_2 ("Sheet1") ' Build XML string Dim xml As String xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" & vbCrLf _ & "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" & vbCrLf _ & "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" & vbCrLf _ & "</Table>" ' Import data from an XML string into worksheet starting with A1 cell Set xlsWorksheet = workbook.easy_getSheetAt(0) xlsWorksheet.easy_insertXMLFromString_3 xml, "A1" ' Export Excel file workbook.easy_WriteXLSXFile ("C:\Samples\XML to Excel.xlsx")

' Create an instance of the class that exports Excel files set workbook = CreateObject("EasyXLS.ExcelDocument") ' Create one sheet workbook.easy_addWorksheet_2 ("Sheet1") ' Build XML string Dim xml xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" & _ "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" & _ "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" & _ "</Table>" ' Import data from an XML string into worksheet starting with A1 cell set xlsWorksheet = workbook.easy_getSheetAt(0) xlsWorksheet.easy_insertXMLFromString_3 xml, "A1" ' Export Excel file workbook.easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx")

<!-- Create an instance of the class that exports Excel files --> <cfobject type="java" class="EasyXLS.ExcelDocument" name="workbook" action="CREATE"> <!-- Create one sheet --> <cfset ret = workbook.easy_addWorksheet("Sheet1")> <!-- Build XML string --> <cfset xml = "<?xml version='1.0'?><Table><![CDATA[Generated by EasyXLS]]>" & "<Row><Data>Value 1</Data><Data>Value 2</Data></Row>" & "<Row><Data>Value 3</Data><Data>Value 4</Data></Row>" & "</Table>"> <!-- Import data from an XML string into worksheet starting with A1 cell --> <cfset xlsWorksheet = workbook.easy_getSheetAt(0)> <cfset xlsWorksheet.easy_insertXMLFromString(xml, "A1")> <!-- Export Excel file --> <cfset ret = workbook.easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx")>



Convert XML to XLSX EasyXLS allows you to convert XML to Excel XLSX file. The above code sample shows how to achieve this goal, by using ExcelDocument.easy_WriteXLSXFile method. See also:

Convert XML to XLSB EasyXLS allows you to convert XML to Excel XLSB file. Similarly, as shown in the above code sample, using ExcelDocument.easy_WriteXLSBFile method, the XML file can be converted to XLSB file. See also:

Convert XML to XLS EasyXLS allows you to convert XML to Excel XLS file. Similarly, as shown in the above code sample, using ExcelDocument.easy_WriteXLSFile method, the XML file can be converted to XLS file. See also:

Convert XML string to Excel EasyXLS library allows importing data from XML string to Excel using ExcelWorksheet.easy_insertXMLFromString method. The above code sample shows how to achieve this goal.

Convert XML file to Excel EasyXLS library allows importing data from XML file using ExcelWorksheet.easy_insertXMLFromFile method similarly, as presented in the above code sample.

Convert XML Spreadsheet file to Excel EasyXLS allows you to convert XML Spreadsheet to Excel XLSX, XLSB or XLS file.

See also:



Getting started with EasyXLS Excel library To download the trial version of EasyXLS Excel Library, press the below button:







If you already own a license key, you may login and download EasyXLS from your account.



See also:



Related methods: