koda

koda

<? Php
ini_set ('display_errors', 1);
require_once ( 'PHPExcel.php');
require_once ( 'PHPExcel / IOFactory.php');
include_once ( '../../../ wp-load.php');
$ objPHPExcel = nytt PHPExcel ();
global $ wpdb;
// $ objPHPExcel-> getActiveSheet ();

$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('A1', 'Donation Reports');
$ objPHPExcel-> setActiveSheetIndex (0) -> mergeCells ('A1: C1', ");
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('A2', 'SI');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('B2', 'Project');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('C2', 'Subprojekt');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('D2', 'Plats');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('E2', 'Total');

$ file = 'Donation'. tid (). 'Xlsx'; //
// $ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007');
// $ objWriter-> save ("upload / excelsheet /". $ file);
// Byt namn på arbetsbladet
$ objPHPExcel-> getActiveSheet () -> setTitle ('Price Matrix');

// Ange aktivt arkindex till det första arket, så Excel öppnar detta som första arket
$ ObjPHPExcel-> setActiveSheetIndex (0);

$ startdate = $ _REQUEST ['exportstartdate']. ' 00: 00: 00 ';
$ enddate = $ _REQUEST ['exportenddate']. ' 00: 00: 00 ';

$ queryexport = ("SELECT". $ wpdb-> prefix. "user_donating. *,". $ wpdb-> prefix. "val. *, summa (". $ wpdb-> prefix. "user_donating.total_amt) som totalt antal "$ Wpdb-> prefix." User_donating LEFT JOIN ". $ Wpdb-> prefix." Val på ". $ Wpdb-> prefix." User_donating.selection_id = ". $ Wpdb-> prefix." Selections.uniqetime_id VAR posted_date mellan "". $ startdate. "'OCH'". $ enddate. "'GROUP efter projekt, sub_projekt, plats");

$ result = mysql_query ($ queryexport);
$ header = ";
$ i = 3;
$ j = 1;

medan ($ row = mysql_fetch_array ($ result)) {
$ objPHPExcel-> getActiveSheet () -> SetCellValue ('A'. $ i, $ j);
$ objPHPExcel-> getActiveSheet () -> SetCellValue ('B'. $ i, $ row ['project']);
$ objPHPExcel-> getActiveSheet () -> SetCellValue ('C'. $ i, $ row ['sub_project']);
$ objPHPExcel-> getActiveSheet () -> SetCellValue ('D'. $ i, $ row ['location']);
$ objPHPExcel-> getActiveSheet () -> SetCellValue ('E'. $ i, '£' .number_format ($ row ['totalamount'], 2));

$ I ++;
$ J ++;
}

$ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007');
$ objWriter-> save ("upload / excelsheet /". $ file);
$ file_url = 'ladda upp / excelsheet /'.$-fil;

header ("Content-Type: application / vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header ("Content-Disposition: attachment; filename =". $ file);
rubrik ("Cache-Control: måste-revalidera, post-check = 0, pre-check = 0");
ob_end_clean ();
readfile ($ FILE_URL);
utgång;

?>

BEHÖVER HJÄLP? Klicka här för onlinehjälp