@brief Write a formula to a worksheet cell with a user defined result.
@param worksheet pointer to a lxw_worksheet instance to be updated.
@param row The zero indexed row number.
@param col The zero indexed column number.
@param formula Formula string to write to cell.
@param format A pointer to a Format instance or NULL.
@param result A user defined result for a formula.
@return A #lxw_error code.
The %worksheet_write_formula_num() function writes a formula or Excel
function to the cell specified by row and column with a user defined
result:
@code
// Required as a workaround only.
worksheet_write_formula_num(worksheet, 0, 0, "=1 + 2", NULL, 3);
@endcode
Libxlsxwriter doesn't calculate the value of a formula and instead stores
the value 0 as the formula result. It then sets a global flag in the XLSX
file to say that all formulas and functions should be recalculated when the
file is opened.
This is the method recommended in the Excel documentation and in general it
works fine with spreadsheet applications.
However, applications that don't have a facility to calculate formulas,
such as Excel Viewer, or some mobile applications will only display the 0
results.
If required, the %worksheet_write_formula_num() function can be used to
specify a formula and its result.
This function is rarely required and is only provided for compatibility
with some third party applications. For most applications the
worksheet_write_formula() function is the recommended way of writing
formulas.
@brief Write a formula to a worksheet cell with a user defined result.
@param worksheet pointer to a lxw_worksheet instance to be updated. @param row The zero indexed row number. @param col The zero indexed column number. @param formula Formula string to write to cell. @param format A pointer to a Format instance or NULL. @param result A user defined result for a formula.
@return A #lxw_error code.
The %worksheet_write_formula_num() function writes a formula or Excel function to the cell specified by row and column with a user defined result:
@code // Required as a workaround only. worksheet_write_formula_num(worksheet, 0, 0, "=1 + 2", NULL, 3); @endcode
Libxlsxwriter doesn't calculate the value of a formula and instead stores the value 0 as the formula result. It then sets a global flag in the XLSX file to say that all formulas and functions should be recalculated when the file is opened.
This is the method recommended in the Excel documentation and in general it works fine with spreadsheet applications.
However, applications that don't have a facility to calculate formulas, such as Excel Viewer, or some mobile applications will only display the 0 results.
If required, the %worksheet_write_formula_num() function can be used to specify a formula and its result.
This function is rarely required and is only provided for compatibility with some third party applications. For most applications the worksheet_write_formula() function is the recommended way of writing formulas.