Global row read type

Function Prototype

1
setType(array $type)
Copied!

Test data preparation

1
$config = ['path' => './tests'];
2
$excel = new \Vtiful\Kernel\Excel($config);
3
4
$filePath = $excel->fileName('tutorial.xlsx')
5
->header(['Name', 'Age', 'Date'])
6
->data([
7
['Viest', 24]
8
])
9
->insertDate(1, 2, 1568877706)
10
->output();
Copied!

Example

1
$data = $excel->openFile('tutorial.xlsx')
2
->openSheet()
3
->setType([
4
\Vtiful\Kernel\Excel::TYPE_STRING,
5
\Vtiful\Kernel\Excel::TYPE_INT,
6
\Vtiful\Kernel\Excel::TYPE_TIMESTAMP,
7
])
8
->getSheetData();
9
10
var_dump($data);
Copied!

Sample output

1
array(2) {
2
[0]=>
3
Array(3) {
4
[0]=>
5
String(4) "Name"
6
[1]=>
7
String(3) "Age"
8
[2]=>
9
String(4) "Date"
10
}
11
[1]=>
12
Array(3) {
13
[0]=>
14
String(5) "Viest"
15
[1]=>
16
Int(24)
17
[2]=>
18
Int(1568877706)
19
}
20
}
Copied!
Last modified 2yr ago