Jump to content

Need help with loop in writing to excel


Recommended Posts

Local $aArray1D[1][5] = [["Index","AssetTag","Description","Location","Date"]]

;write Columns Titles on A1 thru E1
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray1D, "A1")

;loop through sections along with its values
$i = IniReadSectionNames($fileloc)
$a = 0
Local $getindex = IniRead($fileloc, $i[1], "index", "default")
Local $getasset = IniRead($fileloc, $i[1], "Asset", "default")
Local $getdes = IniRead($fileloc, $i[1], "Des", "default")
Local $getloc = IniRead($fileloc, $i[1], "Loc", "default")
Local $getdate = IniRead($fileloc, $i[1], "Date", "default")
Local $aArray2D[1][5]=[[$getindex,$getasset,$getdes,$getloc,$getdate]]

For $i[1] = 1 to UBound($i)-1
$a += 1
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, , "A"&$a+1)
$i += 1
Next

I have a total of 4 record and it loop correctly, but when it writes on excel, the first record gets repeated on excel... I tried multiple ways, but stuck on how to get it work correctly...

 

 

 

EDIT: Nvm, I just put the variables inside the loop and it works...

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

There is no need to write data in a loop to Excel - actually it is just slow.
Pass a variable, a 1D or 2D array to _Excel_RangeWrite.

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

I stumble across a topic about ini to excel and thought I give it a shot for project. I've done a write direct to excel and it's much faster, but with this project; I just wanted to test out varieties way of exporting from ini to other format.

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
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...