瀏覽代碼

Fix: header line no and sheet checkout not init line no

viest 4 年之前
父節點
當前提交
2814997e18
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      kernel/excel.c

+ 10 - 1
kernel/excel.c

@@ -377,6 +377,11 @@ PHP_METHOD(vtiful_xls, checkoutSheet)
 
     line = sheet_t->table->cached_row_num + 1;
 
+    // sheet not insert data
+    if (sheet_t->table->cached_row_num > LXW_ROW_MAX) {
+        line = 0;
+    }
+
     SHEET_LINE_SET(obj, line);
 
     obj->write_ptr.worksheet = sheet_t;
@@ -479,7 +484,11 @@ PHP_METHOD(vtiful_xls, header)
          type_writer(header_value, 0, header_l_key, &obj->write_ptr, NULL, format_handle);
     ZEND_HASH_FOREACH_END();
 
-    SHEET_LINE_ADD(obj)
+    // When inserting the header for the first time, the row number is incremented by one,
+    // and there is no need to increment by one again for subsequent calls.
+    if (obj->write_line == 0) {
+        SHEET_LINE_ADD(obj)
+    }
 }
 /* }}} */