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.
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.
// 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 sheetDim workbook As New ExcelDocument(1)
' Build XML stringDim 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 cellDim xlsWorksheet As ExcelWorksheet = workbook.easy_getSheetAt(0)
xlsWorksheet.easy_insertXMLFromString(Xml, "A1")
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx")
C++// 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 stringchar* 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");
C++.NET// 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");
.NET:// 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");
Java:// Create an instance of the class that exports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Create one sheet
$workbook->easy_addWorksheet("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($xml, "A1");
// Export Excel file
$workbook->easy_WriteXLSXFile("C:\Samples\XML to Excel.xlsx");
' Create an instance of the class that exports Excel filesset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Create one sheet
workbook.easy_addWorksheet_2("Sheet1")
' Build XML stringDim 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 cellset 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 filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Create one sheet
workbook.easy_addWorksheet_2 ("Sheet1")
' Build XML stringDim 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 cellSet 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 filesset workbook = CreateObject("EasyXLS.ExcelDocument")
' Create one sheet
workbook.easy_addWorksheet_2 ("Sheet1")
' Build XML stringDim 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 cellset 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")>
.NET:# Create an instance of the class that exports Excel files, having one sheet
workbook = ExcelDocument(1)
# 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(xml, "A1")
# Optionally, export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\XML to Excel.xlsx")
Java:# Create an instance of the class that exports Excel files, having one sheet
workbook = gateway.jvm.ExcelDocument(1)
# 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(xml, "A1")
# Optionally, export Excel file
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.
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.
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.
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.
// Create an instance of the class that imports Excel files
ExcelDocument workbook = new ExcelDocument();
// Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
' Create an instance of the class that imports Excel filesDim workbook As New ExcelDocument
' Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile("C:\Samples\XML Spreadsheet.xml");
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\XML Spreadsheet to Excel.xlsx");
C++// Create an instance of the class that imports Excel files
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
// Import XML Spreadsheet Excel file
workbook->easy_LoadXMLSpreadsheetFile_2("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
Click here to see Continuous Code ListingC++.NET// Create an instance of the class that imports Excel files
ExcelDocument ^workbook = gcnew ExcelDocument();
// Import XML Spreadsheet Excel file
workbook->easy_LoadXMLSpreadsheetFile("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
Click here to see Continuous Code Listing
// Create an instance of the class that imports Excel files
ExcelDocument workbook = new ExcelDocument();
// Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
// Create an instance of the class that imports Excel files
ExcelDocument workbook = new ExcelDocument();
// Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook.easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
.NET:// Create an instance of the class that imports Excel files
$workbook = new COM("EasyXLS.ExcelDocument");
// Import XML Spreadsheet Excel file
workbook->easy_LoadXMLSpreadsheetFile_2("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
Click here to see Continuous Code ListingJava:// Create an instance of the class that imports Excel files
$workbook = new java("EasyXLS.ExcelDocument");
// Import XML Spreadsheet Excel file
workbook->easy_LoadXMLSpreadsheetFile("C:\\Samples\\XML Spreadsheet.xml");
// Export Excel file
workbook->easy_WriteXLSXFile("C:\\Samples\\XML Spreadsheet to Excel.xlsx");
Click here to see Continuous Code Listing
' Create an instance of the class that imports Excel filesSet workbook = Server.CreateObject("EasyXLS.ExcelDocument")
' Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile_2("C:\Samples\XML Spreadsheet.xml")
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\XML Spreadsheet to Excel.xlsx")
' Create an instance of the class that imports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile_2("C:\Samples\XML Spreadsheet.xml")
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\XML Spreadsheet to Excel.xlsx")
' Create an instance of the class that imports Excel filesSet workbook = CreateObject("EasyXLS.ExcelDocument")
' Import XML Spreadsheet Excel file
workbook.easy_LoadXMLSpreadsheetFile_2("C:\Samples\XML Spreadsheet.xml")
' Export Excel file
workbook.easy_WriteXLSXFile("C:\Samples\XML Spreadsheet to Excel.xlsx")
<!-- Create an instance of the class that imports Excel files --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><!-- Import XML Spreadsheet Excel file --><cfset ret = workbook.easy_LoadXMLSpreadsheetFile("C:\Samples\XML Spreadsheet.xml")><!-- Export Excel file --><cfset ret = workbook.easy_WriteXLSXFile("C:\Samples\XML Spreadsheet to Excel.xlsx")>