Skip to content

Commit

Permalink
Merge pull request #157 from viest/dev
Browse files Browse the repository at this point in the history
version 1.2.7
  • Loading branch information
viest authored Sep 6, 2019
2 parents c59c44f + 8b47d5a commit 3a15642
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 17 deletions.
19 changes: 14 additions & 5 deletions kernel/excel.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ ZEND_BEGIN_ARG_INFO_EX(xls_set_row_arginfo, 0, 0, 3)
ZEND_ARG_INFO(0, range)
ZEND_ARG_INFO(0, height)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(xls_open_file_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, zs_file_name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(xls_open_sheet_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, zs_sheet_name)
ZEND_END_ARG_INFO()
/* }}} */

/** {{{ \Vtiful\Kernel\xls::__construct(array $config)
Expand Down Expand Up @@ -648,11 +656,11 @@ PHP_METHOD(vtiful_xls, openFile)
*/
PHP_METHOD(vtiful_xls, openSheet)
{
zend_string *sheet_name = NULL;
zend_string *zs_sheet_name = NULL;

ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_STR(sheet_name)
Z_PARAM_STR(zs_sheet_name)
ZEND_PARSE_PARAMETERS_END();

ZVAL_COPY(return_value, getThis());
Expand All @@ -663,7 +671,7 @@ PHP_METHOD(vtiful_xls, openSheet)
RETURN_NULL();
}

obj->read_ptr.sheet_t = sheet_open(obj->read_ptr.file_t, sheet_name);
obj->read_ptr.sheet_t = sheet_open(obj->read_ptr.file_t, zs_sheet_name);
}
/* }}} */

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

#ifdef ENABLE_READER
PHP_ME(vtiful_xls, openFile, NULL, ZEND_ACC_PUBLIC)
PHP_ME(vtiful_xls, openSheet, NULL, ZEND_ACC_PUBLIC)
PHP_ME(vtiful_xls, openFile, xls_open_file_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(vtiful_xls, openSheet, xls_open_sheet_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(vtiful_xls, getSheetData, NULL, ZEND_ACC_PUBLIC)
PHP_ME(vtiful_xls, nextRow, NULL, ZEND_ACC_PUBLIC)
#endif

PHP_FE_END
Expand Down
5 changes: 3 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<email>wjx@php.net</email>
<active>yes</active>
</lead>
<date>2019-09-01</date>
<time>11:50:00</time>
<date>2019-09-06</date>
<time>22:10:00</time>
<version>
<release>1.2.7</release>
<api>1.2.7</api>
Expand All @@ -28,6 +28,7 @@
<license uri="https://github.com/viest/php-ext-excel-export/blob/master/LICENSE">BSD license</license>
<notes>
- FEAT read xlsx file.
- FIX multiple file segmentation fault.
</notes>
<contents>
<dir name="/">
Expand Down
6 changes: 1 addition & 5 deletions tests/open_xlsx_file.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ var_dump($data);
@unlink(__DIR__ . '/tutorial.xlsx');
?>
--EXPECT--
object(Vtiful\Kernel\Excel)#1 (4) {
object(Vtiful\Kernel\Excel)#1 (2) {
["config":"Vtiful\Kernel\Excel":private]=>
array(1) {
["path"]=>
string(7) "./tests"
}
["fileName":"Vtiful\Kernel\Excel":private]=>
string(21) "./tests/tutorial.xlsx"
["handle"]=>
NULL
["path"]=>
NULL
}
51 changes: 51 additions & 0 deletions tests/open_xlsx_next_row.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--TEST--
Check for vtiful presence
--SKIPIF--
<?php
require __DIR__ . '/include/skipif.inc';
skip_disable_reader();
?>
--FILE--
<?php
$config = ['path' => './tests'];
$excel = new \Vtiful\Kernel\Excel($config);
$filePath = $excel->fileName('tutorial.xlsx')
->header(['Item', 'Cost'])
->data([
['Item_1', 'Cost_1'],
])
->output();

$excel->openFile('tutorial.xlsx')
->openSheet();

var_dump($excel->nextRow());
var_dump($excel->nextRow());
var_dump($excel->nextRow());
var_dump($excel->nextRow());
var_dump($excel->nextRow());
var_dump($excel->nextRow());
var_dump($excel->nextRow());
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/tutorial.xlsx');
?>
--EXPECT--
array(2) {
[0]=>
string(4) "Item"
[1]=>
string(4) "Cost"
}
array(2) {
[0]=>
string(6) "Item_1"
[1]=>
string(6) "Cost_1"
}
NULL
NULL
NULL
NULL
NULL
6 changes: 1 addition & 5 deletions tests/open_xlsx_sheet.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ var_dump($data);
@unlink(__DIR__ . '/tutorial.xlsx');
?>
--EXPECT--
object(Vtiful\Kernel\Excel)#1 (4) {
object(Vtiful\Kernel\Excel)#1 (2) {
["config":"Vtiful\Kernel\Excel":private]=>
array(1) {
["path"]=>
string(7) "./tests"
}
["fileName":"Vtiful\Kernel\Excel":private]=>
string(21) "./tests/tutorial.xlsx"
["handle"]=>
NULL
["path"]=>
NULL
}

0 comments on commit 3a15642

Please sign in to comment.