Browse Source

Merge branch 'master' into dev

viest 2 years ago
parent
commit
5a00d9f705

+ 7 - 7
kernel/excel.c

@@ -627,7 +627,8 @@ PHP_METHOD(vtiful_xls, header)
  */
 PHP_METHOD(vtiful_xls, data)
 {
-    zend_ulong column_index = 0;
+    zend_ulong column_index = 0, index;
+    zend_string *key;
     zval *data = NULL, *data_r_value = NULL;
 
     ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -651,17 +652,16 @@ PHP_METHOD(vtiful_xls, data)
 
         column_index = 0;
 
-        ZEND_HASH_FOREACH_BUCKET(Z_ARRVAL_P(data_r_value), Bucket *bucket)
+        ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(data_r_value), index, key, data) {
             // numeric index rewriting
-            if (bucket->key == NULL) {
-                column_index = bucket->h;
+            if (key == NULL) {
+                column_index = index;
             }
-
-            type_writer(&bucket->val, SHEET_CURRENT_LINE(obj), column_index, &obj->write_ptr, NULL, obj->format_ptr.format);
+            type_writer(data, SHEET_CURRENT_LINE(obj), column_index, &obj->write_ptr, NULL, obj->format_ptr.format);
 
             // next number index
             ++column_index;
-        ZEND_HASH_FOREACH_END();
+        } ZEND_HASH_FOREACH_END();
 
         SHEET_LINE_ADD(obj)
     ZEND_HASH_FOREACH_END();

+ 7 - 1
kernel/write.c

@@ -355,7 +355,13 @@ void set_row(zend_string *range, double height, xls_resource_write_t *res, lxw_f
  */
 void validation(xls_resource_write_t *res, zend_string *range, lxw_data_validation *validation)
 {
-    worksheet_data_validation_cell(res->worksheet, CELL(ZSTR_VAL(range)), validation);
+    char *rangeStr = ZSTR_VAL(range);
+        
+    if (strchr(rangeStr, ':')) {
+	    worksheet_data_validation_range(res->worksheet, RANGE(rangeStr), validation);
+    } else {
+	    worksheet_data_validation_cell(res->worksheet, CELL(rangeStr), validation);
+    }
 }
 
 /*

+ 42 - 7
package.xml

@@ -33,11 +33,11 @@
   <email>[email protected]</email>
   <active>yes</active>
  </lead>
- <date>2021-10-07</date>
- <time>11:00:00</time>
+ <date>2021-05-01</date>
+ <time>00:00:00</time>
  <version>
-  <release>1.5.0</release>
-  <api>1.5.0</api>
+  <release>1.5.2</release>
+  <api>1.5.2</api>
  </version>
  <stability>
   <release>stable</release>
@@ -45,9 +45,8 @@
  </stability>
  <license uri="https://github.com/viest/php-ext-excel-export/blob/master/LICENSE">BSD license</license>
  <notes>
-- Feat set current line.
-- Feat get current line.
-- Feat rich string.
+- Fix: Write failure on data reference.
+- Fix: String is not zero-terminatedpage.
  </notes>
  <contents>
   <dir name="/">
@@ -206,6 +205,8 @@
    <file md5sum="9badb50b14bd81536bafcfefcb5677d6" name="tests/column_index_from_string.phpt" role="test" />
    <file md5sum="" name="tests/const_memory.phpt" role="test" />
    <file md5sum="da803170bdbbdc8191123889c187d9fa" name="tests/const_memory_index_out_range.phpt" role="test" />
+   <file md5sum="" name="tests/data_reference.phpt" role="test" />
+   <file md5sum="" name="tests/data_string_key.phpt" role="test" />
    <file md5sum="64c92ab74560df6044f1a9019458a5b4" name="tests/default_format.phpt" role="test" />
    <file md5sum="8c30c3f3d54a0b52a26f187c7334a020" name="tests/exist_sheet.phpt" role="test" />
    <file md5sum="84ef50a4df8d5ce312246676a4c933fa" name="tests/first.phpt" role="test" />
@@ -310,6 +311,40 @@
   <configureoption default="yes" name="enable-reader" prompt="enable reader supports?" />
  </extsrcrelease>
  <changelog>
+  <release>
+   <date>2021-10-27</date>
+   <time>00:00:00</time>
+   <version>
+    <release>1.5.1</release>
+    <api>1.5.1</api>
+   </version>
+   <stability>
+    <release>stable</release>
+    <api>stable</api>
+   </stability>
+   <license uri="https://github.com/viest/php-ext-excel-export/blob/master/LICENSE">BSD license</license>
+   <notes>
+    - Feat customize to enable or disable zip64.
+   </notes>
+  </release>
+  <release>
+   <date>2021-10-07</date>
+   <time>11:00:00</time>
+   <version>
+    <release>1.5.0</release>
+    <api>1.5.0</api>
+   </version>
+   <stability>
+    <release>stable</release>
+    <api>stable</api>
+   </stability>
+   <license uri="https://github.com/viest/php-ext-excel-export/blob/master/LICENSE">BSD license</license>
+   <notes>
+    - Feat set current line.
+    - Feat get current line.
+    - Feat rich string.
+   </notes>
+  </release>
   <release>
    <date>2021-07-18</date>
    <time>06:11:08</time>

+ 1 - 1
php_xlswriter.h

@@ -18,7 +18,7 @@
 extern zend_module_entry xlswriter_module_entry;
 #define phpext_xlswriter_ptr &xlswriter_module_entry
 
-#define PHP_XLSWRITER_VERSION "1.5.0"
+#define PHP_XLSWRITER_VERSION "1.5.2"
 #define PHP_XLSWRITER_AUTHOR  "Jiexing.Wang ([email protected])"
 
 #ifdef PHP_WIN32

+ 1 - 0
tests/timestamp_from_date_double.phpt

@@ -4,6 +4,7 @@ Check for vtiful presence
 <?php if (!extension_loaded("xlswriter")) print "skip"; ?>
 --FILE--
 <?php
+ini_set('date.timezone', 'UTC');
 var_dump(\Vtiful\Kernel\Excel::timestampFromDateDouble(43727.306782407));
 var_dump(\Vtiful\Kernel\Excel::timestampFromDateDouble(NULL));
 var_dump(\Vtiful\Kernel\Excel::timestampFromDateDouble(43727));

+ 25 - 0
tests/validation_limiting_to_a_single_or_range_cell.phpt

@@ -0,0 +1,25 @@
+--TEST--
+Check for vtiful presence
+--SKIPIF--
+<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
+--FILE--
+<?php
+$config = ['path' => './tests'];
+
+$validation = new \Vtiful\Kernel\Validation();
+$validation->validationType(\Vtiful\Kernel\Validation::TYPE_LIST)
+    ->valueList(['wjx', 'viest']);
+
+$excel    = new \Vtiful\Kernel\Excel($config);
+$filePath = $excel->fileName('tutorial.xlsx')
+    ->validation('A1', $validation->toResource())
+    ->validation('B1:B1048576', $validation->toResource())
+    ->output();
+
+var_dump($validation, $filePath);
+?>
+--EXPECT--
+object(Vtiful\Kernel\Validation)#1 (0) {
+}
+string(21) "./tests/tutorial.xlsx"
+