Code

Code

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

$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('A1', 'Spendenberichte');
$ objPHPExcel-> setActiveSheetIndex (0) -> mergeCells ('A1: C1', ");
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('A2', 'SI');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('B2', 'Projekt');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('C2', 'Unterprojekt');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('D2', 'Location');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('E2', 'Total');

$ file = 'Spende'. Zeit() . '.xlsx'; //
// $ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007');
// $ objWriter-> save ("upload / excelsheet /". $ file);
// Arbeitsblatt umbenennen
$ objPHPExcel-> getActiveSheet () -> setTitle ('Preismatrix');

// Setze den aktiven Blattindex auf das erste Blatt, also öffnet Excel dies als erstes Blatt
$ objPHPExcel-> setActiveSheetIndex (0);

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

$ queryexport = ("SELECT". $ wpdb-> Präfix "user_donating. *,". $ wpdb-> Präfix. "selections. *, sum (". $ wpdb-> Präfix "user_donating.total_amt) als Gesamtbetrag FROM "Wpdb-> Präfix" user_donating.selection_id = ". $ Wpdb-> Präfix." Selections.uniqetime_id WHERE posted_date zwischen ''. $ startdate. '' UND '". $ enddate.' 'GROUP nach Projekt, sub_project, location");

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

while ($ 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 = 'upload / excelsheet /'.$ Datei;

header ('Content-Type: application / vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header ("Content-Disposition: attachment; Dateiname =". $ file);
Header ("Cache-Control: muss erneut validiert werden, Post-Check = 0, Pre-Check = 0");
ob_end_clean ();
readfile ($ file_url);
exit;

?>

BRAUCHE HILFE? Klicken Sie hier für Online-Hilfe