Operations

From Apache OpenOffice Wiki
< Documentation‎ | DevGuide
Revision as of 15:25, 3 January 2021 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



The cell range interface com.sun.star.sheet.XSheetOperation computes a value based on the contents of all cells of a cell range or clears specific contents of the cells.

  • The method computeFunction() returns the result of the calculation. The constants com.sun.star.sheet.GeneralFunction specify the calculation method.
  • The method clearContents() clears contents of the cells used. The parameter describes the contents to clear, using the constants of com.sun.star.sheet.CellFlags.

The following code shows how to compute the average of a cell range and clear the cell contents:

  // --- Sheet operation. ---
  // Compute a function
  com.sun.star.sheet.XSheetOperation xSheetOp = (com.sun.star.sheet.XSheetOperation)
      UnoRuntime.queryInterface(com.sun.star.sheet.XSheetOperation.class, xCellRange);
 
  double fResult = xSheetOp.computeFunction(com.sun.star.sheet.GeneralFunction.AVERAGE);
  System.out.println("Average value of the data table A10:C30: " + fResult);
 
  // Clear cell contents
  xSheetOp.clearContents(
      com.sun.star.sheet.CellFlags.ANNOTATION | com.sun.star.sheet.CellFlags.OBJECTS);
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages