Sfoglia il codice sorgente

Merge pull request #51 from viest/dev

STYLE(SetFormat): Increase width and Height priority
王杰新 7 anni fa
parent
commit
d8c5ab33e6
3 ha cambiato i file con 20 aggiunte e 16 eliminazioni
  1. 18 14
      kernel/excel.c
  2. 1 1
      tests/011.phpt
  3. 1 1
      tests/012.phpt

+ 18 - 14
kernel/excel.c

@@ -392,21 +392,23 @@ PHP_METHOD(vtiful_xls, setColumn)
     int    argc  = ZEND_NUM_ARGS();
     int    argc  = ZEND_NUM_ARGS();
 
 
     ZEND_PARSE_PARAMETERS_START(2, 3)
     ZEND_PARSE_PARAMETERS_START(2, 3)
-            Z_PARAM_RESOURCE(format_handle)
             Z_PARAM_STR(range)
             Z_PARAM_STR(range)
-            Z_PARAM_OPTIONAL
             Z_PARAM_DOUBLE(width)
             Z_PARAM_DOUBLE(width)
+            Z_PARAM_OPTIONAL
+            Z_PARAM_RESOURCE(format_handle)
     ZEND_PARSE_PARAMETERS_END();
     ZEND_PARSE_PARAMETERS_END();
 
 
     ZVAL_COPY(return_value, getThis());
     ZVAL_COPY(return_value, getThis());
 
 
-    if (argc == 2) {
-        width = 10;
-    }
-
     xls_object *obj = Z_XLS_P(getThis());
     xls_object *obj = Z_XLS_P(getThis());
 
 
-    set_column(range, width, &obj->ptr, zval_get_format(format_handle));
+    if (argc == 3) {
+        set_column(range, width, &obj->ptr, zval_get_format(format_handle));
+    }
+
+    if (argc == 2) {
+        set_column(range, width, &obj->ptr, NULL);
+    }
 }
 }
 /* }}} */
 /* }}} */
 
 
@@ -421,21 +423,23 @@ PHP_METHOD(vtiful_xls, setRow)
     int    argc  = ZEND_NUM_ARGS();
     int    argc  = ZEND_NUM_ARGS();
 
 
     ZEND_PARSE_PARAMETERS_START(2, 3)
     ZEND_PARSE_PARAMETERS_START(2, 3)
-            Z_PARAM_RESOURCE(format_handle)
             Z_PARAM_STR(range)
             Z_PARAM_STR(range)
-            Z_PARAM_OPTIONAL
             Z_PARAM_DOUBLE(height)
             Z_PARAM_DOUBLE(height)
+            Z_PARAM_OPTIONAL
+            Z_PARAM_RESOURCE(format_handle)
     ZEND_PARSE_PARAMETERS_END();
     ZEND_PARSE_PARAMETERS_END();
 
 
     ZVAL_COPY(return_value, getThis());
     ZVAL_COPY(return_value, getThis());
 
 
-    if (argc == 2) {
-        height = 18;
-    }
-
     xls_object *obj = Z_XLS_P(getThis());
     xls_object *obj = Z_XLS_P(getThis());
 
 
-    set_row(range, height, &obj->ptr, zval_get_format(format_handle));
+    if (argc == 3) {
+        set_row(range, height, &obj->ptr, zval_get_format(format_handle));
+    }
+
+    if (argc == 2) {
+        set_row(range, height, &obj->ptr, NULL);
+    }
 }
 }
 /* }}} */
 /* }}} */
 
 

+ 1 - 1
tests/011.phpt

@@ -14,7 +14,7 @@ $boldStyle = \Vtiful\Kernel\Format::bold($fileHandle);
 
 
 $filePath = $fileObject->header(['name', 'age'])
 $filePath = $fileObject->header(['name', 'age'])
     ->data([['viest', 21]])
     ->data([['viest', 21]])
-    ->setColumn($boldStyle, 'A:A', 200)
+    ->setColumn('A:A', 200, $boldStyle)
     ->output();
     ->output();
 
 
 var_dump($filePath);
 var_dump($filePath);

+ 1 - 1
tests/012.phpt

@@ -14,7 +14,7 @@ $boldStyle = \Vtiful\Kernel\Format::bold($fileHandle);
 
 
 $filePath = $fileObject->header(['name', 'age'])
 $filePath = $fileObject->header(['name', 'age'])
     ->data([['viest', 21]])
     ->data([['viest', 21]])
-    ->setRow($boldStyle, 'A1')
+    ->setRow('A1', 200, $boldStyle)
     ->output();
     ->output();
 
 
 var_dump($filePath);
 var_dump($filePath);