Difference between revisions of "Documentation/DevGuide/Spreadsheets/Operations"
From Apache OpenOffice Wiki
		< Documentation | DevGuide
		
		
| OOoWikiBot (talk | contribs) m (FINAL VERSION FOR L10N) | |||
| Line 13: | Line 13: | ||
| * The method <code>clearContents()</code> clears contents of the cells used. The parameter describes the contents to clear, using the constants of <idl>com.sun.star.sheet.CellFlags</idl>. | * The method <code>clearContents()</code> clears contents of the cells used. The parameter describes the contents to clear, using the constants of <idl>com.sun.star.sheet.CellFlags</idl>. | ||
| The following code shows how to compute the average of a cell range and clear the cell contents: | The following code shows how to compute the average of a cell range and clear the cell contents: | ||
| − | + | <syntaxhighlight lang="java"> | |
|    // --- Sheet operation. --- |    // --- Sheet operation. --- | ||
|    // Compute a function |    // Compute a function | ||
| Line 25: | Line 25: | ||
|    xSheetOp.clearContents( |    xSheetOp.clearContents( | ||
|        com.sun.star.sheet.CellFlags.ANNOTATION | com.sun.star.sheet.CellFlags.OBJECTS); |        com.sun.star.sheet.CellFlags.ANNOTATION | com.sun.star.sheet.CellFlags.OBJECTS); | ||
| − | + | </syntaxhighlight> | |
| {{PDL1}} | {{PDL1}} | ||
| [[Category:Documentation/Developer's Guide/Spreadsheet Documents]] | [[Category:Documentation/Developer's Guide/Spreadsheet Documents]] | ||
Latest revision as of 15:25, 3 January 2021
 
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). | 

