Jockem Posted December 29, 2014 Share Posted December 29, 2014 Is it possible to use autoit to convert a .xlsx file to a .cfg file? Link to comment Share on other sites More sharing options...
Mat Posted December 29, 2014 Share Posted December 29, 2014 Yes. Open the the spreadsheet using Excel.au3 UDF, read data, then write data (config files are normally text files, so FileOpen+FileWrite+FileFlush as normal) Could you give an example of the spreadsheet content and what the config file looks like? AutoIt Project Listing Link to comment Share on other sites More sharing options...
Jockem Posted December 29, 2014 Author Share Posted December 29, 2014 This is my script,It now opens PDF but i can't make it open Cfg. #include <Excel.au3> #include <MsgBoxConstants.au3> Local $oAppl = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oAppl, "C:testnagiosscriptnagios logs.cfg" , True) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example", "Error opening workbook '" & "C:testnagiosscriptnagios.xlsx" & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oAppl) Exit EndIf Local $sOutput = "C:testnagiosscriptnagios.xlsx" _Excel_Export($oAppl, "A1:E6", $sOutput, Default, Default, Default, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example 1", "Error saving range to '" & $sOutput & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example 1", "Range successfully exported as '" & $sOutput & "'.") Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 29, 2014 Moderators Share Posted December 29, 2014 Why are you trying to open the Nagios log with Excel? Can you please post the log to this thread, so we can see what you're trying to do? I've done conversion of their log files before, but only with Perl, and never with Excel. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Jockem Posted December 30, 2014 Author Share Posted December 30, 2014 I am doing a project for a college, he supplied the information in an Excel file but he wants a script wich reads excel and writes away as a cfg file. I got my information in an excel sheet, i need to convert this to a cfg file, i just dont know how and in the extract function it only allows you to choose pdf or xps so thats not it but i coudnt find anything els to convert it to a cfg file. Link to comment Share on other sites More sharing options...
Solution water Posted December 30, 2014 Solution Share Posted December 30, 2014 You coul use _Excel_BookSaveAs to save the workbook as text. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Jockem Posted December 30, 2014 Author Share Posted December 30, 2014 (edited) if i do that i copy a piece of the help function but i dont know what variable to put at $xlhtml because it doesnt specify anthing, please help me _Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlHtml) Edited December 30, 2014 by Jockem Link to comment Share on other sites More sharing options...
Jfish Posted December 30, 2014 Share Posted December 30, 2014 The excel conststants file has all the file types which can be found here (copied from the ExcelConstants.au3 file): These are the text ones that may interest you. Global Const $xlTextMSDOS = 21 ; MSDOS Text Global Const $xlTextPrinter = 36 ; Printer Text Global Const $xlTextWindows = 20 ; Windows Text Global Const $xlUnicodeText = 42 ; Unicode Text Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
Jockem Posted December 31, 2014 Author Share Posted December 31, 2014 (edited) Thanks for the tip but now if i run the script i dont get a fault message, so i got that going for me wich is nice but also nothing happens... What do i miss??? _Excel_BookSaveAs ( "C:testnagiosscriptnagios.xlsx", "C:testnagiosscriptnagios.txt", $xlTextWindows ) Could some one post an example please, im really stuck Edited December 31, 2014 by Jockem Link to comment Share on other sites More sharing options...
Jockem Posted December 31, 2014 Author Share Posted December 31, 2014 I fixed it, thanks for the help guys! 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