Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some formula one @ are added #512

Open
fabioebner opened this issue Feb 14, 2025 · 0 comments
Open

Some formula one @ are added #512

fabioebner opened this issue Feb 14, 2025 · 0 comments

Comments

@fabioebner
Copy link

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant