Skip to content

Commit 8b47d5a

Browse files
committed
version 1.2.7
1 parent 160b595 commit 8b47d5a

File tree

5 files changed

+70
-17
lines changed

5 files changed

+70
-17
lines changed

kernel/excel.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ ZEND_BEGIN_ARG_INFO_EX(xls_set_row_arginfo, 0, 0, 3)
146146
ZEND_ARG_INFO(0, range)
147147
ZEND_ARG_INFO(0, height)
148148
ZEND_END_ARG_INFO()
149+
150+
ZEND_BEGIN_ARG_INFO_EX(xls_open_file_arginfo, 0, 0, 1)
151+
ZEND_ARG_INFO(0, zs_file_name)
152+
ZEND_END_ARG_INFO()
153+
154+
ZEND_BEGIN_ARG_INFO_EX(xls_open_sheet_arginfo, 0, 0, 1)
155+
ZEND_ARG_INFO(0, zs_sheet_name)
156+
ZEND_END_ARG_INFO()
149157
/* }}} */
150158

151159
/** {{{ \Vtiful\Kernel\xls::__construct(array $config)
@@ -648,11 +656,11 @@ PHP_METHOD(vtiful_xls, openFile)
648656
*/
649657
PHP_METHOD(vtiful_xls, openSheet)
650658
{
651-
zend_string *sheet_name = NULL;
659+
zend_string *zs_sheet_name = NULL;
652660

653661
ZEND_PARSE_PARAMETERS_START(0, 1)
654662
Z_PARAM_OPTIONAL
655-
Z_PARAM_STR(sheet_name)
663+
Z_PARAM_STR(zs_sheet_name)
656664
ZEND_PARSE_PARAMETERS_END();
657665

658666
ZVAL_COPY(return_value, getThis());
@@ -663,7 +671,7 @@ PHP_METHOD(vtiful_xls, openSheet)
663671
RETURN_NULL();
664672
}
665673

666-
obj->read_ptr.sheet_t = sheet_open(obj->read_ptr.file_t, sheet_name);
674+
obj->read_ptr.sheet_t = sheet_open(obj->read_ptr.file_t, zs_sheet_name);
667675
}
668676
/* }}} */
669677

@@ -720,9 +728,10 @@ zend_function_entry xls_methods[] = {
720728
PHP_ME(vtiful_xls, setRow, xls_set_row_arginfo, ZEND_ACC_PUBLIC)
721729

722730
#ifdef ENABLE_READER
723-
PHP_ME(vtiful_xls, openFile, NULL, ZEND_ACC_PUBLIC)
724-
PHP_ME(vtiful_xls, openSheet, NULL, ZEND_ACC_PUBLIC)
731+
PHP_ME(vtiful_xls, openFile, xls_open_file_arginfo, ZEND_ACC_PUBLIC)
732+
PHP_ME(vtiful_xls, openSheet, xls_open_sheet_arginfo, ZEND_ACC_PUBLIC)
725733
PHP_ME(vtiful_xls, getSheetData, NULL, ZEND_ACC_PUBLIC)
734+
PHP_ME(vtiful_xls, nextRow, NULL, ZEND_ACC_PUBLIC)
726735
#endif
727736

728737
PHP_FE_END

package.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<email>[email protected]</email>
1616
<active>yes</active>
1717
</lead>
18-
<date>2019-09-01</date>
19-
<time>11:50:00</time>
18+
<date>2019-09-06</date>
19+
<time>22:10:00</time>
2020
<version>
2121
<release>1.2.7</release>
2222
<api>1.2.7</api>
@@ -28,6 +28,7 @@
2828
<license uri="https://github.com/viest/php-ext-excel-export/blob/master/LICENSE">BSD license</license>
2929
<notes>
3030
- FEAT read xlsx file.
31+
- FIX multiple file segmentation fault.
3132
</notes>
3233
<contents>
3334
<dir name="/">

tests/open_xlsx_file.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ var_dump($data);
2222
@unlink(__DIR__ . '/tutorial.xlsx');
2323
?>
2424
--EXPECT--
25-
object(Vtiful\Kernel\Excel)#1 (4) {
25+
object(Vtiful\Kernel\Excel)#1 (2) {
2626
["config":"Vtiful\Kernel\Excel":private]=>
2727
array(1) {
2828
["path"]=>
2929
string(7) "./tests"
3030
}
3131
["fileName":"Vtiful\Kernel\Excel":private]=>
3232
string(21) "./tests/tutorial.xlsx"
33-
["handle"]=>
34-
NULL
35-
["path"]=>
36-
NULL
3733
}

tests/open_xlsx_next_row.phpt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
$filePath = $excel->fileName('tutorial.xlsx')
13+
->header(['Item', 'Cost'])
14+
->data([
15+
['Item_1', 'Cost_1'],
16+
])
17+
->output();
18+
19+
$excel->openFile('tutorial.xlsx')
20+
->openSheet();
21+
22+
var_dump($excel->nextRow());
23+
var_dump($excel->nextRow());
24+
var_dump($excel->nextRow());
25+
var_dump($excel->nextRow());
26+
var_dump($excel->nextRow());
27+
var_dump($excel->nextRow());
28+
var_dump($excel->nextRow());
29+
?>
30+
--CLEAN--
31+
<?php
32+
@unlink(__DIR__ . '/tutorial.xlsx');
33+
?>
34+
--EXPECT--
35+
array(2) {
36+
[0]=>
37+
string(4) "Item"
38+
[1]=>
39+
string(4) "Cost"
40+
}
41+
array(2) {
42+
[0]=>
43+
string(6) "Item_1"
44+
[1]=>
45+
string(6) "Cost_1"
46+
}
47+
NULL
48+
NULL
49+
NULL
50+
NULL
51+
NULL

tests/open_xlsx_sheet.phpt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ var_dump($data);
2222
@unlink(__DIR__ . '/tutorial.xlsx');
2323
?>
2424
--EXPECT--
25-
object(Vtiful\Kernel\Excel)#1 (4) {
25+
object(Vtiful\Kernel\Excel)#1 (2) {
2626
["config":"Vtiful\Kernel\Excel":private]=>
2727
array(1) {
2828
["path"]=>
2929
string(7) "./tests"
3030
}
3131
["fileName":"Vtiful\Kernel\Excel":private]=>
3232
string(21) "./tests/tutorial.xlsx"
33-
["handle"]=>
34-
NULL
35-
["path"]=>
36-
NULL
3733
}

0 commit comments

Comments
 (0)