Jump to content
Sign in to follow this  
Queener

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

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 2020-09-05 - Version 1.5.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (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
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...