Skip to content

Commit 7000ccf

Browse files
committed
Fix: read: Turning data into custom types
1 parent 077f403 commit 7000ccf

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

tests/fix-207.phpt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/include/skipif.inc';
6+
skip_disable_reader();
7+
?>
8+
--FILE--
9+
<?php
10+
$config = ['path' => './tests'];
11+
$excel = new \Vtiful\Kernel\Excel($config);
12+
13+
$filePath = $excel->fileName('tutorial.xlsx')
14+
->header(['Name', 'Code'])
15+
->data([
16+
['Viest', '00024']
17+
])
18+
->output();
19+
20+
$dataOne = $excel->openFile('tutorial.xlsx')
21+
->openSheet()
22+
->setType([
23+
\Vtiful\Kernel\Excel::TYPE_STRING,
24+
\Vtiful\Kernel\Excel::TYPE_STRING,
25+
])
26+
->getSheetData();
27+
28+
$dataTwo = $excel->openFile('tutorial.xlsx')
29+
->openSheet()
30+
->setType([
31+
\Vtiful\Kernel\Excel::TYPE_STRING,
32+
\Vtiful\Kernel\Excel::TYPE_INT,
33+
])
34+
->getSheetData();
35+
36+
var_dump($dataOne);
37+
var_dump($dataTwo);
38+
?>
39+
--CLEAN--
40+
<?php
41+
@unlink(__DIR__ . '/tutorial.xlsx');
42+
?>
43+
--EXPECT--
44+
array(2) {
45+
[0]=>
46+
array(2) {
47+
[0]=>
48+
string(4) "Name"
49+
[1]=>
50+
string(4) "Code"
51+
}
52+
[1]=>
53+
array(2) {
54+
[0]=>
55+
string(5) "Viest"
56+
[1]=>
57+
string(5) "00024"
58+
}
59+
}
60+
array(2) {
61+
[0]=>
62+
array(2) {
63+
[0]=>
64+
string(4) "Name"
65+
[1]=>
66+
string(4) "Code"
67+
}
68+
[1]=>
69+
array(2) {
70+
[0]=>
71+
string(5) "Viest"
72+
[1]=>
73+
int(24)
74+
}
75+
}

tests/open_xlsx_get_data_with_set_type.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ array(2) {
4848
[0]=>
4949
string(5) "Viest"
5050
[1]=>
51-
int(24)
51+
string(2) "24"
5252
[2]=>
5353
int(1568877706)
5454
}

0 commit comments

Comments
 (0)