1 : <?php
2 : require_once "JetPlugin.class.php";
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :
11 :
12 :
13 :
14 : class JetExcelDownload extends JetPlugin{
15 : public function __construct(){
16 4 : $this->key = "excel";
17 4 : }
18 :
19 : public function action($header, $records){
20 0 : require_once "Spreadsheet\Excel\Writer.php";
21 :
22 0 : $workbook = new Spreadsheet_Excel_Writer();
23 0 : $worksheet =& $workbook->addWorksheet("list");
24 0 : $format =& $workbook->addFormat();
25 0 : $format->_font_name = mb_convert_encoding("sjis", "sjis");
26 :
27 0 : $i = 0;
28 0 : foreach($header as $headerKey=>$headerValue){
29 0 : $worksheet->write(0, $i, mb_convert_encoding($headerValue, "sjis", "euc-jp"));
30 0 : $i++;
31 0 : }
32 :
33 0 : $i = 1;
34 0 : foreach($records as $record){
35 0 : $j = 0;
36 0 : foreach($header as $headerKey=>$headerValue){
37 0 : $worksheet->write($i, $j, mb_convert_encoding($record[$headerKey], "sjis", "euc-jp"));
38 0 : $j++;
39 0 : }
40 0 : $i++;
41 0 : }
42 :
43 0 : $workbook->send("list.xls");
44 0 : $workbook->close();
45 :
46 0 : die();
47 : }
48 : }
49 : ?>
|