Difference between revisions of "Documentation/DevGuide/Spreadsheets/Operations"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
m (Robot: Changing Category:Spreadsheet Documents)
Line 26: Line 26:
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: Spreadsheet Documents]]
+
 
 +
[[Category:Documentation/Developers Guide/Spreadsheet Documents]]

Revision as of 09:51, 4 June 2008



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