getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); $num = 1; $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A'.$num, 'Section Id') ->setCellValue('B'.$num, 'Category Id') ->setCellValue('C'.$num, 'Sub Category Id') ->setCellValue('D'.$num, 'Item Id') ->setCellValue('E'.$num, 'Section Name') ->setCellValue('F'.$num, 'Category Name') ->setCellValue('G'.$num, 'Sub Category Name') ->setCellValue('H'.$num, 'Item Name') ->setCellValue('I'.$num, 'Local Name') ->setCellValue('J'.$num, 'Item Brand') ->setCellValue('K'.$num, 'Item Detail') ->setCellValue('L'.$num, 'Item Image') ->setCellValue('M'.$num, 'Item Weight') ->setCellValue('N'.$num, 'Weight Type') ->setCellValue('O'.$num, 'Price') ->setCellValue('P'.$num, 'Market Price'); $num = 2; $quer = mysql_query("select * from item "); while($rrrr = mysql_fetch_array($quer)) { $cat_id = $rrrr['cat_id']; $id = $rrrr['id']; $sub_cate_id = $rrrr['sub_cate_id']; $section_id = $rrrr['section_id']; $query = mysql_query("select * from product_section where id = '$section_id' "); while($rrr = mysql_fetch_array($query)) { $sec_name = $rrr['sec_name']; } $query = mysql_query("SELECT * FROM item_sub_category where id = '$sub_cate_id' "); while($row = mysql_fetch_array($query)) { $sub_cat_name = $row['sub_cat_name']; } $que = mysql_query("SELECT * FROM item_category where id = '$cat_id' "); while($rrr = mysql_fetch_array($que)) { $cat_name = $rrr['cat_name']; } $trtrtrtr[1] = 'M'; $trtrtrtr[2] = 'N'; $trtrtrtr[3] = 'O'; $trtrtrtr[4] = 'P'; $trtrtrtr[5] = 'Q'; $trtrtrtr[6] = 'R'; $trtrtrtr[7] = 'S'; $trtrtrtr[8] = 'T'; $trtrtrtr[9] = 'U'; $trtrtrtr[10] = 'V'; $trtrtrtr[11] = 'W'; $trtrtrtr[12] = 'X'; $trtrtrtr[13] = 'Y'; $trtrtrtr[14] = 'Z'; $trtrtrtr[15] = 'AA'; $trtrtrtr[16] = 'AB'; $trtrtrtr[17] = 'AC'; $trtrtrtr[18] = 'AD'; $trtrtrtr[19] = 'AE'; $trtrtrtr[20] = 'AF'; $trtrtrtr[21] = 'AG'; $trtrtrtr[22] = 'AH'; $trtrtrtr[23] = 'AI'; $trtrtrtr[24] = 'AJ'; $trtrtrtr[25] = 'AK'; $trtrtrtr[26] = 'AL'; $trtrtrtr[27] = 'AM'; $trtrtrtr[28] = 'AN'; $trtrtrtr[29] = 'AO'; $trtrtrtr[30] = 'AP'; $trtrtrtr[31] = 'AQ'; $trtrtrtr[32] = 'AR'; $trtrtrtr[33] = 'AS'; $trtrtrtr[34] = 'AT'; $trtrtrtr[35] = 'AU'; $trtrtrtr[36] = 'AV'; $trtrtrtr[37] = 'AW'; $trtrtrtr[38] = 'AX'; $trtrtrtr[39] = 'AY'; $trtrtrtr[40] = 'AZ'; $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A'.$num, $rrrr['section_id']) ->setCellValue('B'.$num, $rrrr['cat_id']) ->setCellValue('C'.$num, $rrrr['sub_cate_id']) ->setCellValue('D'.$num, $rrrr['id']) ->setCellValue('E'.$num, $sec_name) ->setCellValue('F'.$num, $cat_name) ->setCellValue('G'.$num, $sub_cat_name) ->setCellValue('H'.$num, $rrrr['item_name']) ->setCellValue('I'.$num, $rrrr['other_name']) ->setCellValue('J'.$num, $rrrr['item_brand']) ->setCellValue('K'.$num, $rrrr['itemdetail']) ->setCellValue('L'.$num, $rrrr['itemimage']); $ccnntt = 0; $qued = mysql_query("SELECT * FROM item_price where item_id = '$id' and mode =1 order by weight_type , weight DESC "); $totprcnum = mysql_num_rows($qued); if($totprcnum > 0) { while($sdss = mysql_fetch_array($qued)) { $ccnnttffS[1] = $trtrtrtr[$ccnntt+1]; $ccnnttffS[2] = $trtrtrtr[$ccnntt+2]; $ccnnttffS[3] = $trtrtrtr[$ccnntt+3]; $ccnnttffS[4] = $trtrtrtr[$ccnntt+4]; $ccnntt = $ccnntt+4; $weight_type = $sdss['weight_type']; $weight = $sdss['weight']; $price = $sdss['price']; $market_price = $sdss['market_price']; $objPHPExcel->setActiveSheetIndex(0) ->setCellValue($ccnnttffS[1].$num, $weight) ->setCellValue($ccnnttffS[2].$num, $weight_type) ->setCellValue($ccnnttffS[3].$num, $price) ->setCellValue($ccnnttffS[4].$num, $market_price); } } $ccnntt = 0; $num++; } // Rename worksheet $objPHPExcel->getActiveSheet()->setTitle('Simple'); // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Excel5) header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="itemlist.xls"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header ('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit; } mysql_close();