Exporting results to Excel
Posted on 2005-04-06
I need to display a list of dealers on screen that are grouped by state and alphabetized. All states need to be shown.
In addition, each dealer needs to have a checkbox next to dealer name.
For Example, I need to show the following on screen:
Result 1-->(checkbox) Dealer1 in state1
(checkbox) Dealer2 in state1
(checkbox)DealerX in state1
Result 2--> (checkbox)Dealer1 in state2
(checkbox)Dealer2 in state2
(checkbox)DealerX in state2
Result 2--> (checkbox)Dealer1 in stateX
(checkbox)Dealer2 in stateX
(checkbox)DealerX in stateX
this is my sql query to retrieve the data ==> "select dealer_id, name FROM `dealer` order by state,name"
1. I would like to loop through the result set to see whether or not the "state" field changes. When it does, I want to start a new column. Then after x columns have been created on the page, i want to move 2 rows down to begin with the next column. Does anyone have a code example for this or anything similar?
Once dealers are shown by state with a checkbox next to the dealer name, the user should be able to select X number of dealers and then click submit.
This would execute the following query ==> "select name, state,zipcode from dealers where dealer_id(which will be passed in the checkbox) in (1,2,.,n)"
The results need to open within microsoft excel with the following format:
name1 zip2 (located in column B in Excel)
name2 zip2 (located in column B in Excel)
nameX zipX (located in column B in Excel)
1. How can i have microsoft excel automatically open with the result set within the worksheet?
2. How can I format the sheet to display my desired format above?
Codes sample would be highly appreciated.