fastexcel icon indicating copy to clipboard operation
fastexcel copied to clipboard

Some formula one @ are added

Open fabioebner opened this issue 1 year ago • 1 comments

I trying to genereate one xlsx file. with a fomrula in a cell a basic formula

=IF(I2="";"";CONCAT(I2;LEFT(T2;1)))

but when I open the excel the formula was changed to

=@IF(I2="";"";CONCAT(I2;LEFT(T2;1)))

and the cell dont show anything until I manually remove the @

Image

this is my code:

ws.formula(dataRowIndex,coluna.getXlsxColumnOrder(),xmlEscape(formula));

and the xmlEscape method

    public static String xmlEscape(String input) {
        if (input == null) {
            return null;
        }

        // A ordem de substituição é importante para evitar substituições duplas
        // Primeiro substituímos '&', para não "bagunçar" as substituições dos outros caracteres.
        String escaped = input.replace("&", "&");

        // Agora substituímos os demais.
        escaped = escaped.replace("<", "&lt;");
        escaped = escaped.replace(">", "&gt;");
        escaped = escaped.replace("\"", "&quot;");
        escaped = escaped.replace("'", "&apos;");

        return escaped;
    }

fabioebner avatar Feb 14 '25 13:02 fabioebner