浏览代码

STYLE(SetFormat): Increase width and Height priority

viest 7 年之前
父节点
当前提交
d6f7712cfe
共有 3 个文件被更改,包括 20 次插入16 次删除
  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();
 
     ZEND_PARSE_PARAMETERS_START(2, 3)
-            Z_PARAM_RESOURCE(format_handle)
             Z_PARAM_STR(range)
-            Z_PARAM_OPTIONAL
             Z_PARAM_DOUBLE(width)
+            Z_PARAM_OPTIONAL
+            Z_PARAM_RESOURCE(format_handle)
     ZEND_PARSE_PARAMETERS_END();
 
     ZVAL_COPY(return_value, getThis());
 
-    if (argc == 2) {
-        width = 10;
-    }
-
     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();
 
     ZEND_PARSE_PARAMETERS_START(2, 3)
-            Z_PARAM_RESOURCE(format_handle)
             Z_PARAM_STR(range)
-            Z_PARAM_OPTIONAL
             Z_PARAM_DOUBLE(height)
+            Z_PARAM_OPTIONAL
+            Z_PARAM_RESOURCE(format_handle)
     ZEND_PARSE_PARAMETERS_END();
 
     ZVAL_COPY(return_value, getThis());
 
-    if (argc == 2) {
-        height = 18;
-    }
-
     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'])
     ->data([['viest', 21]])
-    ->setColumn($boldStyle, 'A:A', 200)
+    ->setColumn('A:A', 200, $boldStyle)
     ->output();
 
 var_dump($filePath);

+ 1 - 1
tests/012.phpt

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