kods

kods

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

$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('A1', 'Ziedojumu pārskati');
$ objPHPExcel-> setActiveSheetIndex (0) -> mergeCells ('A1: C1', ");
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('A2', 'SI');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('B2', 'Project');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('C2', 'Sub Project');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('D2', 'Atrašanās vieta');
$ objPHPExcel-> setActiveSheetIndex (0) -> setCellValue ('E2', 'Kopā');

$ file = 'Ziedojums'. laiks() . '.xlsx'; //
// $ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007');
// $ objWriter-> saglabāt ("upload / excelsheet /". $ file);
// Pārdēvēt darblapu
$ objPHPExcel-> getActiveSheet () -> setTitle ('Cena Matrix');

// Iestatiet aktīvo lapu indeksu pirmajai lapai, lai Excel to atvērtu kā pirmo lapu
$ objPHPExcel-> setActiveSheetIndex (0);

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

$ queryexport = ("SELECT". $ wpdb-> prefikss. "user_donating. *,". $ wpdb-> prefikss. "izvēles. *, summa (". $ wpdb-> prefikss. "user_donating.total_amt) "$ Wpdb-> prefikss" user_donating LEFT JOIN ". $ Wpdb-> prefikss." Atlase ON ". $ Wpdb-> prefikss." User_donating.selection_id = ". $ Wpdb-> prefikss." Selections.uniqetime_id WHERE posted_date starp "". $ startdate. "" UN "". $ enddate. "" GRUPA pēc projekta, sub_project, atrašanās vieta ");

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

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

$ I ++;
$ j ++;
}

$ objWriter = PHPExcel_IOFactory :: createWriter ($ objPHPExcel, 'Excel2007');
$ objWriter-> saglabāt ("upload / excelsheet /". $ file);
$ file_url = 'upload / excelsheet /'.$ file;

galvenes ('Content-Type: application / vnd.openxmlformats-officedocument.spreadsheetml.sheet');
galvenes ("Content-Disposition: attachment; filename =". $ file);
galvene ("Cache-Control: must-revalidate, post-check = 0, pre-check = 0");
ob_end_clean ();
lasīt failu ($ file_url);
Izeja;

?>

VAJADZĪGA PALĪDZĪBA? Klikšķiniet šeit, lai tiešsaistes palīdzību