-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSalz_spreadsheet.php
More file actions
100 lines (88 loc) · 2.52 KB
/
Copy pathSalz_spreadsheet.php
File metadata and controls
100 lines (88 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
*
* Created by Mochammad Faisal
* Created at 2023-05-12 09:05:11
* Updated at
*
*/
use PhpOffice\PhpSpreadsheet\Spreadsheet;
// use PhpOffice\PhpSpreadsheet\IOFactory;
// use PhpOffice\PhpSpreadsheet\Writer\IWriter;
// use PhpOffice\PhpSpreadsheet\Reader\IReader;
class Salz_spreadsheet {
public $excel_formating;
public $file_mimes;
private $file_ext;
function __construct() {
$this->excel_formating = [
'stringFormat' => [
'text' => '@',
],
'numberFormat' => [
'commaStyle' => '_-* #,##0_-;-* #,##0_-;_-* "-"_-;_-@_-',
'percentage' => [
'default' => '0%',
'1dec' => '0.0%',
'2dec' => '0.00%',
],
],
'dateFormat' => [
'date' => 'yyyy-mm-dd',
'time' => 'hh:mm:ss',
'datetime' => 'yyyy-mm-dd hh:mm:ss',
]
];
$this->file_mimes = [
'text/x-comma-separated-values',
'text/comma-separated-values',
'application/octet-stream',
'application/vnd.ms-excel',
'application/x-csv',
'text/x-csv',
'text/csv',
'application/csv',
'application/excel',
'application/vnd.msexcel',
'text/plain',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
];
$this->file_ext = [
'reader' => [
'Xlsx',
'Xls',
'Xml',
'Ods',
'Gnumeric',
'Html',
'Slk',
'Csv'
],
'writer' => [
'Xlsx',
'Xls',
'Ods',
'Html',
'Pdf',
'Csv'
]
];
}
function init() {
return new Spreadsheet();
}
function init_writer($spreadsheet, $file_ext) {
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, $file_ext);
return $writer;
}
function init_reader($filename, $file_ext = '') {
if (!empty($file_ext)) {
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($file_ext);
$data = $reader->load($filename);
} else {
$data = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
}
return $data;
}
// end of class
}