Jump to content
Sign in to follow this  
Jockem

.xlsx to .cfg?

Recommended Posts

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 & "'.")

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

You coul use _Excel_BookSaveAs to save the workbook as text.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 by Jockem

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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  :wacko:

Edited by Jockem

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...