Skip to content

[Bug] Escaped percent in a number format (0\%) multiplies the value by 100 when reading #1114

Description

@nkuprins

Search before asking

  • I searched in the issues and found nothing similar.

Fesod version

main

JDK version

any

Operating system

Linux

Steps To Reproduce

File file = new File("escaped-percent.xlsx");

DataFormatData dataFormat = new DataFormatData();
dataFormat.setFormat("0\\%");

WriteCellData<BigDecimal> cell = new WriteCellData<>(new BigDecimal("5"));
cell.getOrCreateStyle().setDataFormatData(dataFormat);

FesodSheet.write(file)
        .head(Collections.singletonList(Collections.singletonList("rate")))
        .sheet()
        .doWrite(Collections.singletonList(Collections.singletonList(cell)));

System.out.println(FesodSheet.read(file).sheet().doReadSync());

Current Behavior

[{0=500%}]

The \% escape is dropped and the value is multiplied by 100, so the cell that displays as 5% reads
back as 500%.

Expected Behavior

[{0=5%}]

The read value should match what the spreadsheet displays, as it does for every other format.

Anything else?

Found while writing the tests in #1110.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions