JamesDover Posted April 6, 2012 Posted April 6, 2012 (edited) I am running a mysql query that pulls down dates and department. I would like to output this into a excel file how ever I can't seem to get each rows to separate. I would like to have Departments in one row and Dates in another row. Thanks in advance. Example of output: 04/26/201404/26/201404/26/201404/26/201404/26/201404/26/201404/26/201404/26/201404/26/2014 Func ComputerModel() $SQLInstance5 = _MySQLConnect($UserName, $Password, $Database, $MySQLServerName) $Model = "" $Model2 = "" $NametoFind3 = GUICtrlRead($Userid) ;This pulls from the gui $RemoteFormatString4 = "SELECT * FROM accountinfo WHERE fields_15 BETWEEN '04/26/2014' AND '04/31/2014';" $SQLCode5 = StringFormat($RemoteFormatString4, $NametoFind3) $TableContents5 = _Query($SQLInstance5, $SQLCode5) With $TableContents5 While Not .EOF $Model &= .Fields("fields_15").value $Model2 &= .Fields("Department").value .MoveNext WEnd EndWith ;Write Excel Local $oExcel = _ExcelBookNew() Local $aArray[5][2] = [[$Model, 1],[$Model2, 2],["big_daddy", 3],["DaleHolm", 4],["GaryFrost", 5]] ;0-Base Array _ExcelWriteSheetFromArray($oExcel, $aArray, 1, 1, 0, 0) ;0-Base Array parameters _MySQLEnd($SQLInstance5) EndFunc ;==>ComputerModel Edited April 6, 2012 by JamesDover
JohnOne Posted April 6, 2012 Posted April 6, 2012 I don't have excel. I'm no expert (especially with StringFormat) But it looks to me like you are using it totally wrong there. How did you get it to that? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Juvigy Posted April 9, 2012 Posted April 9, 2012 (edited) This is what is wrong: While Not .EOF $Model &= .Fields("fields_15").value $Model2 &= .Fields("Department").value .MoveNext WEnd Instead if it try: Dim $Model[1][2] $i=0 While Not .EOF $Model[$i][0] = .Fields("fields_15").value $Model[$i][1] = .Fields("Department").value .MoveNext $i = $i+1 Redim $Model[$i+1][2] WEnd _arraydisplay($Model) Edited April 9, 2012 by Juvigy JamesDover 1
JamesDover Posted April 10, 2012 Author Posted April 10, 2012 That worked great thanks. I now have a problem with the mysql date query. The format of the database is mm-dd-yyyy not the default YYYY-MM-DD format. So when it filters it. It puts the same year togather but this will be a question for mysql. James
Juvigy Posted April 11, 2012 Posted April 11, 2012 You can change the formatting of the date in excel easily if you dont want to do it in MySQL.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now