kernel/write.c
/*
 * According to the zval type written to the file
 */
According to the zval type written to the file
According to the zval type written to the file
void type_writer(zval *value, zend_long row, zend_long columns, xls_resource_write_t *res, zend_string *format, lxw_format *format_handle)
{
    lxw_format *value_format = NULL;
    lxw_col_t lxw_col = (lxw_col_t)columns;
    lxw_row_t lxw_row = (lxw_row_t)row;
    zend_uchar value_type = Z_TYPE_P(value);
    if (value_type == IS_STRING) {
        zend_string *_zs_value = zval_get_string(value);
        int error = worksheet_write_string(res->worksheet, lxw_row, lxw_col, ZSTR_VAL(_zs_value), format_handle);
        zend_string_release(_zs_value);
        WORKSHEET_WRITER_EXCEPTION(error);
        return;
    }
    if (value_type == IS_LONG) {
        if (format != NULL && format_handle == NULL) {
            value_format = workbook_add_format(res->workbook);
            format_set_num_format(value_format, ZSTR_VAL(format));
            WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, (double)zval_get_long(value), value_format));
            return;
        }
        if (format == NULL && format_handle != NULL) {
            WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, (double)zval_get_long(value), format_handle));
            return;
        }
        if(format != NULL && format_handle != NULL) {
            value_format = workbook_add_format(res->workbook);
            format_copy(value_format, format_handle);
            format_set_num_format(value_format, ZSTR_VAL(format));
            WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, (double)zval_get_long(value), value_format));
            return;
        }
        WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, (double)zval_get_long(value), NULL));
    }
    if (value_type == IS_DOUBLE) {
        if (format != NULL && format_handle == NULL) {
            value_format = workbook_add_format(res->workbook);
            format_set_num_format(value_format, ZSTR_VAL(format));
            WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, zval_get_double(value), value_format));
            return;
        }
        if (format == NULL && format_handle != NULL) {
            WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, zval_get_double(value), format_handle));
            return;
        }
        if(format != NULL && format_handle != NULL) {
            value_format = workbook_add_format(res->workbook);
            format_copy(value_format, format_handle);
            format_set_num_format(value_format, ZSTR_VAL(format));
            WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, lxw_row, lxw_col, zval_get_double(value), value_format));
            return;
        }
        WORKSHEET_WRITER_EXCEPTION(worksheet_write_number(res->worksheet, (lxw_row_t)row, (lxw_col_t)columns, zval_get_double(value), NULL));
        return;
    }
}
void type_writer ( zval * value , zend_long row , zend_long columns , xls_resource_write_t * res , zend_string * format , lxw_format * format_handle ) { lxw_format * value_format = NULL ; lxw_col_t lxw_col = ( lxw_col_t ) columns ; lxw_row_t lxw_row = ( lxw_row_t ) row ; zend_uchar value_type = Z_TYPE_P ( value ) ; if ( value_type == IS_STRING ) { zend_string * _zs_value = zval_get_string ( value ) ; int error = worksheet_write_string ( res -> worksheet , lxw_row , lxw_col , ZSTR_VAL ( _zs_value ) , format_handle ) ; zend_string_release ( _zs_value ) ; WORKSHEET_WRITER_EXCEPTION ( error ) ; return ; } if ( value_type == IS_LONG ) { if ( format != NULL && format_handle == NULL ) { value_format = workbook_add_format ( res -> workbook ) ; format_set_num_format ( value_format , ZSTR_VAL ( format ) ) ; WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , ( double ) zval_get_long ( value ) , value_format ) ) ; return ; } if ( format == NULL && format_handle != NULL ) { WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , ( double ) zval_get_long ( value ) , format_handle ) ) ; return ; } if ( format != NULL && format_handle != NULL ) { value_format = workbook_add_format ( res -> workbook ) ; format_copy ( value_format , format_handle ) ; format_set_num_format ( value_format , ZSTR_VAL ( format ) ) ; WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , ( double ) zval_get_long ( value ) , value_format ) ) ; return ; } WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , ( double ) zval_get_long ( value ) , NULL ) ) ; } if ( value_type == IS_DOUBLE ) { if ( format != NULL && format_handle == NULL ) { value_format = workbook_add_format ( res -> workbook ) ; format_set_num_format ( value_format , ZSTR_VAL ( format ) ) ; WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , zval_get_double ( value ) , value_format ) ) ; return ; } if ( format == NULL && format_handle != NULL ) { WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , zval_get_double ( value ) , format_handle ) ) ; return ; } if ( format != NULL && format_handle != NULL ) { value_format = workbook_add_format ( res -> workbook ) ; format_copy ( value_format , format_handle ) ; format_set_num_format ( value_format , ZSTR_VAL ( format ) ) ; WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , lxw_row , lxw_col , zval_get_double ( value ) , value_format ) ) ; return ; } WORKSHEET_WRITER_EXCEPTION ( worksheet_write_number ( res -> worksheet , ( lxw_row_t ) row , ( lxw_col_t ) columns , zval_get_double ( value ) , NULL ) ) ; return ; } }
According to the zval type written to the file
According to the zval type written to the file