DigDeep Posted July 18, 2016 Share Posted July 18, 2016 Can someone please guide me if there is a way to Open XML file as XLS? Or if we can convert XML to XLS file format. I have an xml file which contains list of lines and when I open it in xls format the contents appear in columns and rows automatically. Which is the way I am looking for... Link to comment Share on other sites More sharing options...
Danyfirex Posted July 18, 2016 Share Posted July 18, 2016 You can use _Excel_BookSaveAs from _Excel udf. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
DigDeep Posted July 18, 2016 Author Share Posted July 18, 2016 I am still facing some issues here getting the error for "Error Opening WorkBook..." I am trying to Open $XML > Read the lines > and Save the file in $XLS format. $XML = "C:\Temp\Scan.xml" $XLS = "C:\Temp\Final.xls" Func Convert() ; Create application object and open an example workbook Local $XLS = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($XLS, $XML) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error opening workbook '" & @ScriptDir & $XLS & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($XLS) Exit EndIf ; ***************************************************************************** ; Save the workbook (xls) in another format (html) to another directory and ; overwrite an existing version ; ***************************************************************************** Local $sWorkbook = "C:\Temp\Scan.xml" _Excel_BookSaveAs($sWorkbook, $oWorkbook, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Error saving workbook to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Workbook successfully saved as '" & $sWorkbook & "'.") ;~ ShellExecute($sWorkbook) EndFunc ;==>ConvertToXLS Convert() Link to comment Share on other sites More sharing options...
Danyfirex Posted July 18, 2016 Share Posted July 18, 2016 (edited) Try this. #include <Excel.au3> Local $sSourceFileXML = "C:\Users\xxx\Desktop\1.xml" Local $sFinalFileXLS = "C:\Users\xxx\Desktop\1.xls" _Convert($sSourceFileXML, $sFinalFileXLS) Func _Convert($sXML, $sXLS) Local $oExcel = _Excel_Open(False) If @error Then Return False Local $oWorkbook = _Excel_BookOpen($oExcel, $sXML) If @error Then _Excel_Close($oExcel) Return False EndIf Local $iResult = _Excel_BookSaveAs($oWorkbook, $sXLS) _Excel_Close($oExcel) Return $iResult EndFunc ;==>_Convert Saludos Edited July 18, 2016 by Danyfirex DigDeep, Skysnake and Gianni 3 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
DigDeep Posted July 18, 2016 Author Share Posted July 18, 2016 This works good. Except that once xls is created while opening it gives error for file format. But I think this should work for me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now