Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $c=1;
- while($row = mysql_result($query)) {
- // put your data into an array that will match the columns
- $data = array(
- '', // will be an empty because there is no column 0
- $row['last'], // will be for column A
- $row['first'],// will be for column B
- $row['phone']
- );
- // your also going to have to have something here for letters
- $alpha = array(
- '', // need an empty
- 'A',
- 'B',
- 'C', // etc..
- );
- // set active sheet
- $objPHPExcel->setActiveSheetIndex(0);
- // now for a loop to put it together
- for($i=0; $i<count($data); $i++) {
- // make sure we aren't looking at the empty one
- if ($i > 0) {
- $objPHPExcel->setCellValue($alpha[$i].$c, $data[$i]);
- // example: $objPHPExcel->setCellValue('A1', 'Carlson');
- }// end if
- }// end for loop
- // increment counter for the row
- $c++;
- }// end while
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement