Skip to content

Commit 48bf53c

Browse files
authored
Merge pull request #435 from viest/dev
Dev
2 parents f300a00 + 4faf34e commit 48bf53c

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

kernel/excel.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ PHP_METHOD(vtiful_xls, data)
637637
WORKBOOK_NOT_INITIALIZED(obj);
638638

639639
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), data_r_value)
640+
if (Z_TYPE_P(data_r_value) == IS_REFERENCE) {
641+
data_r_value = Z_REFVAL_P(data_r_value);
642+
}
643+
640644
if(Z_TYPE_P(data_r_value) != IS_ARRAY) {
641645
continue;
642646
}

kernel/help.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ zend_long date_double_to_timestamp(double value) {
3838
}
3939
smart_str_append_long(&_modify_arg_string, days);
4040
smart_str_appendl(&_modify_arg_string, " days", 5);
41+
ZSTR_VAL(_modify_arg_string.s)[ZSTR_LEN(_modify_arg_string.s)] = '\0';
4142
ZVAL_STR(&_modify_args[0], _modify_arg_string.s);
4243
call_object_method(&datetime, "modify", 1, _modify_args, &_modify_result);
4344
zval_ptr_dtor(&datetime);

tests/data_reference.phpt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
$data = [
11+
[23],
12+
[21],
13+
[21],
14+
[21],
15+
];
16+
17+
foreach($data as &$line) {
18+
$line[0]++;
19+
}
20+
21+
$excel = new \Vtiful\Kernel\Excel([
22+
'path' => './tests',
23+
]);
24+
25+
$fileObject = $excel->constMemory('data_reference.xlsx', NULL, false);
26+
$fileHandle = $fileObject->getHandle();
27+
28+
$path = $fileObject->header(['age'])
29+
->data($data)
30+
->output();
31+
32+
$excel->openFile('data_reference.xlsx')
33+
->openSheet();
34+
35+
var_dump($excel->nextRow());
36+
var_dump($excel->nextRow());
37+
var_dump($excel->nextRow());
38+
var_dump($excel->nextRow());
39+
?>
40+
--CLEAN--
41+
<?php
42+
@unlink(__DIR__ . '/data_reference.xlsx');
43+
?>
44+
--EXPECT--
45+
array(1) {
46+
[0]=>
47+
string(3) "age"
48+
}
49+
array(1) {
50+
[0]=>
51+
int(24)
52+
}
53+
array(1) {
54+
[0]=>
55+
int(22)
56+
}
57+
array(1) {
58+
[0]=>
59+
int(22)
60+
}

0 commit comments

Comments
 (0)