diff --git a/kernel/write.c b/kernel/write.c index 9d4c35d..4adef44 100644 --- a/kernel/write.c +++ b/kernel/write.c @@ -249,9 +249,11 @@ void chart_writer(zend_long row, zend_long columns, xls_resource_chart_t *chart_ */ void datetime_writer(lxw_datetime *datetime, zend_long row, zend_long columns, zend_string *format, xls_resource_write_t *res, lxw_format *format_handle) { - if (format_handle != NULL) { - format_set_num_format(format_handle, ZSTR_VAL(format)); + lxw_format *value_format = format_handle; + if (format_handle == NULL) { + value_format = workbook_add_format(res->workbook); } + format_set_num_format(value_format, ZSTR_VAL(format)); worksheet_write_datetime(res->worksheet, (lxw_row_t)row, (lxw_col_t)columns, datetime, format_handle); }