miachm / SODS

A simple Java library for handle ODS (Open Document Spreadsheet, compatible with Excel and Libreoffice)
The Unlicense
74 stars 30 forks source link

Problem with cross sheets formula, am I doing it wrong ? #56

Open Gniarf opened 1 year ago

Gniarf commented 1 year ago

Hello

first, let me thanks for this project, I have been searching for something equivalent in .net and have given up so I am coding in Java with yours, it's easy to use and efficient.

I am running into a strange problem. If I define a formula that does a very simple sum with data from the same sheet, it works properly. If I define exactly the same formula but taking the data from another sheet, it just does not compute the result.

Sheet sheet = spread.getSheet("Operations"); Range range = sheet.getRange("C2"); range.setValue(13.42); sheet.getRange("C3").setValue(42.65); sheet.getRange("E3").setFormula("SUM(C:C)"); // works fine spread.getSheet("Calculs").getRange("B1").setFormula("SUM(Operations!C:C)"); // the sum is not computed

here is the formula in the generated file : =SUM(operations C:C) instead of =SUM(operations!C:C) note the missing !

I have tried different ways to write it, the result is always the same : the result is not computed. I can still open the file and rewrite the ! and it will do the job, but I need automation.

Am I doing something wrong ?

Thank you

github-actions[bot] commented 1 year ago

Thanks for your report! Please ensure you have provided enough info in order to recreate the issue, including the problematic ODS File.

miachm commented 1 year ago

It seems like a legit error. Not sure why it's removing the (!). It must be something related to the XML file. But it should not happen since (!) is a valid character.

miachm commented 1 year ago

Is this fixed in the latest version? I have tried to generate a file with this symbol and worked fine

Gniarf commented 1 year ago

With the 1.5.4 here's the result :

sheet.getRange(cellId).setFormula("=Type_Operations!$C$1")

And here is what I find the produced ods : =type_operations $C$1

So it's not good :(

miachm commented 1 year ago

Tested the same string and works with LibreOffice 7.5.2.2