Queener

Need help with loop in writing to excel

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.")

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