I am using the LibreOffice SDK to create a Java program that reads data from a Calc spreadsheet. One of the cells has a formula in it that returns text (i.e. not a numeric/double value).
XCell.getFormula() returns the actual formula (“=I6”), rather than the result (“my text”).
I have looked at the LibreOffice SDK API, and it appears that XCell.getValue() will return the formula result, as long as it is a number. There does not appear to be any other methods to return formula results.
I have tried to set the cell type from Number to Text, using getFormula() and getValue(). Neither of these work.
Is there a way to get the textual result of a formula using the LibreOffice SDK?
Many thanks
Fintan
Advertisement
Answer
Try so
XCell xCell = xCellRangesAccess.getCellByPosition(....); XTextRange xTextRange = UnoRuntime.queryInterface(XTextRange.class, xCell); String sString = xTextRange.getString();