Difference between revisions of "Documentation/DevGuide/Spreadsheets/Operations"
From Apache OpenOffice Wiki
< Documentation | DevGuide
m (1 revision(s)) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/Spreadsheets/Multiple Operations | |NextPage=Documentation/DevGuide/Spreadsheets/Multiple Operations | ||
}} | }} | ||
− | {{DISPLAYTITLE:Operations}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Spreadsheets/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Operations}} | ||
<!--<idltopic>com.sun.star.sheet.XSheetOperation</idltopic>--> | <!--<idltopic>com.sun.star.sheet.XSheetOperation</idltopic>--> | ||
The cell range interface <idl>com.sun.star.sheet.XSheetOperation</idl> computes a value based on the contents of all cells of a cell range or clears specific contents of the cells. | The cell range interface <idl>com.sun.star.sheet.XSheetOperation</idl> computes a value based on the contents of all cells of a cell range or clears specific contents of the cells. | ||
Line 12: | 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 24: | 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}} | ||
− | + | [[Category:Documentation/Developer's Guide/Spreadsheet Documents]] | |
− | [[Category: 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). |