Difference between revisions of "Documentation/DevGuide/Spreadsheets/Handling Array Formulas"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
Line 15: Line 15:
 
* The method <code>setArrayFormula()</code> sets an array formula to the complete cell range.
 
* The method <code>setArrayFormula()</code> sets an array formula to the complete cell range.
 
<!--[SOURCE:Spreadsheet/SpreadsheetSample.java]-->
 
<!--[SOURCE:Spreadsheet/SpreadsheetSample.java]-->
 
+
<syntaxhighlight lang="java">
 
   // --- Array formulas ---
 
   // --- Array formulas ---
 
   com.sun.star.sheet.XArrayFormulaRange xArrayFormula = (com.sun.star.sheet.XArrayFormulaRange)
 
   com.sun.star.sheet.XArrayFormulaRange xArrayFormula = (com.sun.star.sheet.XArrayFormulaRange)
Line 22: Line 22:
 
   xArrayFormula.setArrayFormula("=A10:C12");
 
   xArrayFormula.setArrayFormula("=A10:C12");
 
   System.out.println("Array formula is: " + xArrayFormula.getArrayFormula());  
 
   System.out.println("Array formula is: " + xArrayFormula.getArrayFormula());  
 
+
</syntaxhighlight>
 
{{Warn|Due to a bug, this interface does not work correctly in the current implementation. The <tt>getArrayFormula()</tt> method returns the translated function names, but not the English names. The <tt>setArrayFormula()</tt> method accepts English names without preceding equal sign and without curly braces. This is inconsistent to the methods <tt>setFormula()</tt> and <tt>getFormula()</tt> of the interface <idl>com.sun.star.table.XCell</idl>. The latter can be used in order to read the English array formula from one of the used cells.}}
 
{{Warn|Due to a bug, this interface does not work correctly in the current implementation. The <tt>getArrayFormula()</tt> method returns the translated function names, but not the English names. The <tt>setArrayFormula()</tt> method accepts English names without preceding equal sign and without curly braces. This is inconsistent to the methods <tt>setFormula()</tt> and <tt>getFormula()</tt> of the interface <idl>com.sun.star.table.XCell</idl>. The latter can be used in order to read the English array formula from one of the used cells.}}
  

Latest revision as of 15:29, 3 January 2021



The interface com.sun.star.sheet.XArrayFormulaRange handles array formulas.

  • If the whole cell range contains an array formula, the method getArrayFormula() returns the formula string, otherwise an empty string is returned.
  • The method setArrayFormula() sets an array formula to the complete cell range.
  // --- Array formulas ---
  com.sun.star.sheet.XArrayFormulaRange xArrayFormula = (com.sun.star.sheet.XArrayFormulaRange)
      UnoRuntime.queryInterface(com.sun.star.sheet.XArrayFormulaRange.class, xCellRange);
  // Insert a 3x3 unit matrix.
  xArrayFormula.setArrayFormula("=A10:C12");
  System.out.println("Array formula is: " + xArrayFormula.getArrayFormula());
Documentation caution.png Due to a bug, this interface does not work correctly in the current implementation. The getArrayFormula() method returns the translated function names, but not the English names. The setArrayFormula() method accepts English names without preceding equal sign and without curly braces. This is inconsistent to the methods setFormula() and getFormula() of the interface com.sun.star.table.XCell. The latter can be used in order to read the English array formula from one of the used cells.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages