Browse Source

version 1.2.7

viest 5 years ago
parent
commit
8b47d5ac46
5 changed files with 70 additions and 17 deletions
  1. 14 5
      kernel/excel.c
  2. 3 2
      package.xml
  3. 1 5
      tests/open_xlsx_file.phpt
  4. 51 0
      tests/open_xlsx_next_row.phpt
  5. 1 5
      tests/open_xlsx_sheet.phpt

+ 14 - 5
kernel/excel.c

@@ -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)
@@ -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());
@@ -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);
 }
 /* }}} */
 
@@ -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

+ 3 - 2
package.xml

@@ -15,8 +15,8 @@
   <email>[email protected]</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>
@@ -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="/">

+ 1 - 5
tests/open_xlsx_file.phpt

@@ -22,7 +22,7 @@ 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"]=>
@@ -30,8 +30,4 @@ object(Vtiful\Kernel\Excel)#1 (4) {
   }
   ["fileName":"Vtiful\Kernel\Excel":private]=>
   string(21) "./tests/tutorial.xlsx"
-  ["handle"]=>
-  NULL
-  ["path"]=>
-  NULL
 }

+ 51 - 0
tests/open_xlsx_next_row.phpt

@@ -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

+ 1 - 5
tests/open_xlsx_sheet.phpt

@@ -22,7 +22,7 @@ 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"]=>
@@ -30,8 +30,4 @@ object(Vtiful\Kernel\Excel)#1 (4) {
   }
   ["fileName":"Vtiful\Kernel\Excel":private]=>
   string(21) "./tests/tutorial.xlsx"
-  ["handle"]=>
-  NULL
-  ["path"]=>
-  NULL
 }