Jump to content

Export ini data to Excel - (Moved)


 Share

Recommended Posts

Hello,
I would like to import the data saved in the ini file of the program that I prepared with your help before to Excel. For example, I share some of the ini file and my codes.
Thanks to Autoit lovers who will help.

#include <Excel.au3>

Global $Roww, $City, $Vill, $Strt, $Strt, $Iden, $Name, $Damg, $Expl, $pEdit

$Roww = IniRead("AnKcSbData.ini", $Roww, "Roww", "Not Found")
$City = IniRead("AnKcSbData.ini", $Roww, "City", "Not Found")
$Vill = IniRead("AnKcSbData.ini", $Roww, "Vill", "Not Found")
$Strt = IniRead("AnKcSbData.ini", $Roww, "Strt", "Not Found")
$Iden = IniRead("AnKcSbData.ini", $Roww, "Iden", "Not Found")
$Name = IniRead("AnKcSbData.ini", $Roww, "Name", "Not Found")
$Fath = IniRead("AnKcSbData.ini", $Roww, "Fath", "Not Found")
$Damg = IniRead("AnKcSbData.ini", $Roww, "Damg", "Not Found")
$Expl = IniRead("AnKcSbData.ini", $Roww, "Expl", "Not Found")

Local $aArray[3][9] = [[$Roww], [$City], [$Vill], [$Strt], [$Iden], [$Name], [$Fath], [$Damg], [$Expl]]
Local $oExcel = _Excel_Open()
Local $oBook = _Excel_BookNew($oExcel, 1)
$oBook.Activesheet.Range("A1:I9").Value = $aArray

AnKcSbData.ini

[1]
Roww=1
City=NEWYORK / Kaliforniya
Vill=Rose Street
Strt=Duncan Road
Iden=000000000000
Name=George MICHEAL
Fath=Jarry
Damg=Heavily Damaged
Expl=Nothig.

[2]
Roww=2
City=ABD / Texas
Vill=Houston Street
Strt=Austin Road
Iden=111111111111
Name=Jerry Lewis
Fath=Jones
Damg=Slightly Damaged
Expl=Repairable.

[3]
Roww=3
City=
Vill=
Strt=
Iden=
Name=
Fath=
Damg=
Expl=

 

Link to comment
Share on other sites

And your question is?

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

Try:

#include <Excel.au3>
Global $sAnKcSbData = @ScriptDir & "\AnKcSbData.ini"
Global $aSectionNames = IniReadSectionNames($sAnKcSbData)
    If @error Then Exit MsgBox(4096, "Error", "Error Reading Seciton Names")
Global $aAnKcSbData[$aSectionNames[0] + 1][9]
For $i = 1 To $aSectionNames[0]
    $aAnKcSbData[$i - 1][0] = IniRead($sAnKcSbData, $aSectionNames[$i], "Roww", "Not Found")
    $aAnKcSbData[$i - 1][1] = IniRead($sAnKcSbData, $aSectionNames[$i], "City", "Not Found")
    $aAnKcSbData[$i - 1][2] = IniRead($sAnKcSbData, $aSectionNames[$i], "Vill", "Not Found")
    $aAnKcSbData[$i - 1][3] = IniRead($sAnKcSbData, $aSectionNames[$i], "Strt", "Not Found")
    $aAnKcSbData[$i - 1][4] = IniRead($sAnKcSbData, $aSectionNames[$i], "Iden", "Not Found")
    $aAnKcSbData[$i - 1][5] = IniRead($sAnKcSbData, $aSectionNames[$i], "Name", "Not Found")
    $aAnKcSbData[$i - 1][6] = IniRead($sAnKcSbData, $aSectionNames[$i], "Fath", "Not Found")
    $aAnKcSbData[$i - 1][7] = IniRead($sAnKcSbData, $aSectionNames[$i], "Damg", "Not Found")
    $aAnKcSbData[$i - 1][8] = IniRead($sAnKcSbData, $aSectionNames[$i], "Expl", "Not Found")
Next
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookNew($oExcel)
_Excel_RangeWrite($oWorkbook, Default, $aAnKcSbData)

 

Link to comment
Share on other sites

2 minutes ago, Subz said:

Try:

#include <Excel.au3>
Global $sAnKcSbData = @ScriptDir & "\AnKcSbData.ini"
Global $aSectionNames = IniReadSectionNames($sAnKcSbData)
    If @error Then Exit MsgBox(4096, "Error", "Error Reading Seciton Names")
Global $aAnKcSbData[$aSectionNames[0] + 1][9]
For $i = 1 To $aSectionNames[0]
    $aAnKcSbData[$i - 1][0] = IniRead($sAnKcSbData, $aSectionNames[$i], "Roww", "Not Found")
    $aAnKcSbData[$i - 1][1] = IniRead($sAnKcSbData, $aSectionNames[$i], "City", "Not Found")
    $aAnKcSbData[$i - 1][2] = IniRead($sAnKcSbData, $aSectionNames[$i], "Vill", "Not Found")
    $aAnKcSbData[$i - 1][3] = IniRead($sAnKcSbData, $aSectionNames[$i], "Strt", "Not Found")
    $aAnKcSbData[$i - 1][4] = IniRead($sAnKcSbData, $aSectionNames[$i], "Iden", "Not Found")
    $aAnKcSbData[$i - 1][5] = IniRead($sAnKcSbData, $aSectionNames[$i], "Name", "Not Found")
    $aAnKcSbData[$i - 1][6] = IniRead($sAnKcSbData, $aSectionNames[$i], "Fath", "Not Found")
    $aAnKcSbData[$i - 1][7] = IniRead($sAnKcSbData, $aSectionNames[$i], "Damg", "Not Found")
    $aAnKcSbData[$i - 1][8] = IniRead($sAnKcSbData, $aSectionNames[$i], "Expl", "Not Found")
Next
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookNew($oExcel)
_Excel_RangeWrite($oWorkbook, Default, $aAnKcSbData)

 

:thumbsup: Thanks # Subz #

Its works

Link to comment
Share on other sites

  • 2 weeks later...

One way :

#include <Excel.au3>
Global $sAnKcSbData = @ScriptDir & "\AnKcSbData.ini"
Global $aSectionNames = IniReadSectionNames($sAnKcSbData)
    If @error Then Exit MsgBox(4096, "Error", "Error Reading Seciton Names")
Global $aAnKcSbData[$aSectionNames[0] + 1][9], $iCount = 0
For $i = 1 To $aSectionNames[0]
    $aAnKcSbData[$iCount][0] = IniRead($sAnKcSbData, $aSectionNames[$i], "Roww", "Not Found")
    $aAnKcSbData[$iCount][1] = IniRead($sAnKcSbData, $aSectionNames[$i], "City", "Not Found")
    $aAnKcSbData[$iCount][2] = IniRead($sAnKcSbData, $aSectionNames[$i], "Vill", "Not Found")
    $aAnKcSbData[$iCount][3] = IniRead($sAnKcSbData, $aSectionNames[$i], "Strt", "Not Found")
    $aAnKcSbData[$iCount][4] = IniRead($sAnKcSbData, $aSectionNames[$i], "Iden", "Not Found")
    $aAnKcSbData[$iCount][5] = IniRead($sAnKcSbData, $aSectionNames[$i], "Name", "Not Found")
    $aAnKcSbData[$iCount][6] = IniRead($sAnKcSbData, $aSectionNames[$i], "Fath", "Not Found")
    $aAnKcSbData[$iCount][7] = IniRead($sAnKcSbData, $aSectionNames[$i], "Damg", "Not Found")
    $aAnKcSbData[$iCount][8] = IniRead($sAnKcSbData, $aSectionNames[$i], "Expl", "Not Found")
    If $aAnKcSbData[$iCount][1] = "USA / Texas" Then $iCount += 1 ; put all the conditions you want on this line
Next
ReDim $aAnKcSbData[$iCount][9]
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookNew($oExcel)
_Excel_RangeWrite($oWorkbook, Default, $aAnKcSbData)

 

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...