Re: PHPExcel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan Shirah wrote:
GOT IT!!!

I changed my code to the following:


$sql = "SELECT * FROM brev_pending_summary_detail WHERE name =
'$name_code'";
 if (!empty($case_age)) {
  $sql.=" AND case_age_group = '$case_age'";
 }
 if (!empty($case_cat)) {
  $sql.=" AND case_category = '$case_cat'";
 }
 if (!empty($case_status)) {
  $sql.=" AND case_status = '$case_status'";
 } // Start our query of the database
$query = ifx_query($sql, $connect_id);
$row = ifx_fetch_row($query);
$results = array();

echo date('H:i:s') . " Add some data<br />\n";

for ($i = 3, $j = 0; $i <= $count; $i++, $j++) {
 $results[$j] = ifx_fetch_row($query);

 $objPHPExcel->getActiveSheet()->setCellValue('A' . $i,
$results[$j]['stat_year']);
 $objPHPExcel->getActiveSheet()->setCellValue('B' . $i,
$results[$j]['stat_month']);
 $objPHPExcel->getActiveSheet()->setCellValue('C' . $i,
$results[$j]['name']);
 $objPHPExcel->getActiveSheet()->setCellValue('D' . $i,
$results[$j]['case_age_group']);
 }


Give this a try, should save you some memory!

<?php

$sql = "SELECT   *
        FROM     brev_pending_summary_detail
        WHERE    name = '{$name_code}'";
if (!empty($case_age)) {
	$sql.=" AND case_age_group = '{$case_age}'";
}
if (!empty($case_cat)) {
	$sql.=" AND case_category = '{$case_cat}'";
}
if (!empty($case_status)) {
	$sql.=" AND case_status = '{$case_status}'";
} // Start our query of the database


$query = ifx_query($sql, $connect_id);

echo date('H:i:s') . " Add some data<br />\n";

$offSet = 3;

$row = ifx_fetch_row($query, "NEXT");

while ( is_array($row) ) {

	$objPHPExcel->getActiveSheet()->setCellValue('A' . $offSet,
						$row['stat_year']);
	$objPHPExcel->getActiveSheet()->setCellValue('B' . $offSet,
						$row['stat_month']);
	$objPHPExcel->getActiveSheet()->setCellValue('C' . $offSet,
						$row['name']);
	$objPHPExcel->getActiveSheet()->setCellValue('D' . $offSet,
						$row['case_age_group']);

	$offSet++;

	$row = ifx_fetch_row($query, "NEXT");
}
ifx_free_result($query);

?>

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux