Skip to content

Commit

Permalink
Merge pull request #1 from Jan-E/php7-issue241
Browse files Browse the repository at this point in the history
Fix iliaal#241 for PHP7
  • Loading branch information
Jan-E authored Dec 31, 2018
2 parents 6e06f9e + 0720fca commit 40b10b5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 8 deletions.
12 changes: 8 additions & 4 deletions docs/ExcelSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,10 @@ public function horPageBreak($row, $break)
*
* @param int $column_start 0-based column number
* @param int $column_end 0-based column number
* @param bool $update_named_ranges (optional, default=true)
* @return bool
*/
public function insertCol($column_start, $column_end)
public function insertCol($column_start, $column_end, $update_named_ranges = true)
{
} // insertCol

Expand All @@ -784,9 +785,10 @@ public function insertCol($column_start, $column_end)
*
* @param int $row_start 0-based row number
* @param int $row_end 0-based row number
* @param bool $update_named_ranges (optional, default=true)
* @return bool
*/
public function insertRow($row_start, $row_end)
public function insertRow($row_start, $row_end, $update_named_ranges = true)
{
} // insertRow

Expand Down Expand Up @@ -1032,9 +1034,10 @@ public function readRow($row, $column_start = 0, $column_end = -1, $read_formula
*
* @param int $column_start 0-based column number
* @param int $column_end 0-based column number
* @param bool $update_named_ranges (optional, default=true)
* @return bool
*/
public function removeCol($column_start, $column_end)
public function removeCol($column_start, $column_end, $update_named_ranges = true)
{
} // removeCol

Expand All @@ -1053,9 +1056,10 @@ public function removeDataValidations()
*
* @param int $row_start 0-based row number
* @param int $row_end 0-based row number
* @param bool $update_named_ranges (optional, default=true)
* @return bool
*/
public function removeRow($row_start, $row_end)
public function removeRow($row_start, $row_end, $update_named_ranges = true)
{
} // removeRow

Expand Down
49 changes: 45 additions & 4 deletions excel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,19 @@ EXCEL_METHOD(Sheet, writeCol)
RETURN_BOOL(xlSheet ## func_name (sheet, r, c)); \
}

#define PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(func_name) \
{ \
SheetHandle sheet; \
zval *object = getThis(); \
zend_long r, c; \
zend_bool u = 1; \
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &r, &c, &u) == FAILURE) { \
RETURN_FALSE; \
} \
SHEET_FROM_OBJECT(sheet, object); \
RETURN_BOOL(xlSheet ## func_name (sheet, r, c, u)); \
}

/* {{{ proto bool ExcelSheet::isFormula(int row, int column)
Determine if the cell contains a formula */
EXCEL_METHOD(Sheet, isFormula)
Expand Down Expand Up @@ -2615,35 +2628,51 @@ EXCEL_METHOD(Sheet, isDate)
}
/* }}} */

/* {{{ proto bool ExcelSheet::insertRow(int row_first, int row_last)
/* {{{ proto bool ExcelSheet::insertRow(int row_first, int row_last, bool update_named_ranges)
Inserts rows from rowFirst to rowLast */
EXCEL_METHOD(Sheet, insertRow)
{
#if LIBXL_VERSION >= 0x03080301
PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(InsertRow)
#else
PHP_EXCEL_SHEET_GET_BOOL_STATE(InsertRow)
#endif
}
/* }}} */

/* {{{ proto bool ExcelSheet::insertCol(int col_first, int col_last)
/* {{{ proto bool ExcelSheet::insertCol(int col_first, int col_last, bool update_named_ranges)
Inserts columns from colFirst to colLast */
EXCEL_METHOD(Sheet, insertCol)
{
#if LIBXL_VERSION >= 0x03080301
PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(InsertCol)
#else
PHP_EXCEL_SHEET_GET_BOOL_STATE(InsertCol)
#endif
}
/* }}} */

/* {{{ proto bool ExcelSheet::removeRow(int row_first, int row_last)
/* {{{ proto bool ExcelSheet::removeRow(int row_first, int row_last, bool update_named_ranges)
Removes rows from rowFirst to rowLast */
EXCEL_METHOD(Sheet, removeRow)
{
#if LIBXL_VERSION >= 0x03080301
PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(RemoveRow)
#else
PHP_EXCEL_SHEET_GET_BOOL_STATE(RemoveRow)
#endif
}
/* }}} */

/* {{{ proto bool ExcelSheet::removeCol(int col_first, int col_last)
/* {{{ proto bool ExcelSheet::removeCol(int col_first, int col_last, bool update_named_ranges)
Removes columns from colFirst to colLast */
EXCEL_METHOD(Sheet, removeCol)
{
#if LIBXL_VERSION >= 0x03080301
PHP_EXCEL_SHEET_GET_BOOL_STATE_3831(RemoveCol)
#else
PHP_EXCEL_SHEET_GET_BOOL_STATE(RemoveCol)
#endif
}
/* }}} */

Expand Down Expand Up @@ -5798,21 +5827,33 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_insertRow, 0, 0, 2)
ZEND_ARG_INFO(0, row_first)
ZEND_ARG_INFO(0, row_last)
#if LIBXL_VERSION >= 0x03080301
ZEND_ARG_INFO(0, update_named_ranges)
#endif
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_insertCol, 0, 0, 2)
ZEND_ARG_INFO(0, col_first)
ZEND_ARG_INFO(0, col_last)
#if LIBXL_VERSION >= 0x03080301
ZEND_ARG_INFO(0, update_named_ranges)
#endif
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeRow, 0, 0, 2)
ZEND_ARG_INFO(0, row_first)
ZEND_ARG_INFO(0, row_last)
#if LIBXL_VERSION >= 0x03080301
ZEND_ARG_INFO(0, update_named_ranges)
#endif
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_removeCol, 0, 0, 2)
ZEND_ARG_INFO(0, col_first)
ZEND_ARG_INFO(0, col_last)
#if LIBXL_VERSION >= 0x03080301
ZEND_ARG_INFO(0, update_named_ranges)
#endif
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_Sheet_colWidth, 0, 0, 1)
Expand Down

0 comments on commit 40b10b5

Please sign in to comment.