Jump to content

.xlsx to .cfg?


Jockem
 Share

Go to solution Solved by water,

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 & "'.")
Link to comment
Share on other sites

  • Moderators

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

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

  • Solution

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
Link to comment
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

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...