diff --git a/kernel/write.c b/kernel/write.c index 734a5b8..f7486fd 100644 --- a/kernel/write.c +++ b/kernel/write.c @@ -72,6 +72,25 @@ void type_writer(zval *value, zend_long row, zend_long columns, xls_resource_wri WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, (lxw_row_t)row, (lxw_col_t)columns, zval_get_double(value), NULL)); return; } + + if (value_type == IS_TRUE || value_type == IS_FALSE) { + if (format != NULL && format_handle == NULL) { + WORKSHEET_WRITER_EXCEPTION(worksheet_write_boolean(res->worksheet, lxw_row, lxw_col, zend_is_true(value), format_handle)); + return; + } + + if (format == NULL && format_handle != NULL) { + WORKSHEET_WRITER_EXCEPTION(worksheet_write_boolean(res->worksheet, lxw_row, lxw_col, zend_is_true(value), format_handle)); + return; + } + + if(format != NULL && format_handle != NULL) { + WORKSHEET_WRITER_EXCEPTION(worksheet_write_boolean(res->worksheet, lxw_row, lxw_col, zend_is_true(value), format_handle)); + return; + } + + WORKSHEET_WRITER_EXCEPTION(worksheet_write_boolean(res->worksheet, lxw_row, lxw_col, zend_is_true(value), NULL)); + } } /* diff --git a/tests/018.phpt b/tests/018.phpt index d05c8b5..850bc9f 100644 --- a/tests/018.phpt +++ b/tests/018.phpt @@ -9,9 +9,9 @@ $excel = new \Vtiful\Kernel\Excel($config); $fileObject = $excel->fileName("18.xlsx"); -$fileObject->header(['name', 'age']) - ->data([['viest', 21]]) - ->data([['wjx', 21]]); +$fileObject->header(['name', 'age', 'active']) + ->data([['viest', 21, true]]) + ->data([['wjx', 21, false]]); $filePath = $fileObject->output();