Non US Excel functions and syntax
Excel stores formulas in the format of the US English version, regardless of the
language or locale of the end-user's version of Excel. Therefore all formula
function names written using rust_xlsxwriter
must be in English. In addition,
formulas must be written with the US style separator/range operator which is a
comma (not semi-colon).
Some examples of how formulas should and shouldn't be written are shown below:
// SPDX-License-Identifier: MIT OR Apache-2.0
//
// Copyright 2022-2024, John McNamara, jmcnamara@cpan.org
//! The following example demonstrates some common formula syntax errors.
use rust_xlsxwriter::{Workbook, XlsxError};
fn main() -> Result<(), XlsxError> {
let mut workbook = Workbook::new();
let worksheet = workbook.add_worksheet();
// OK.
worksheet.write_formula(0, 0, "=SUM(1, 2, 3)")?;
// Semi-colon separator. Causes Excel error on file opening.
worksheet.write_formula(1, 0, "=SUM(1; 2; 3)")?;
// French function name. Causes Excel error on file opening.
worksheet.write_formula(2, 0, "=SOMME(1, 2, 3)")?;
workbook.save("formula.xlsx")?;
Ok(())
}
If you have a non-English version of Excel you can use the following multi-lingual Formula Translator to help you convert the formula. It can also replace semi-colons with commas.