Difference between revisions of "Documentation/DevGuide/Spreadsheets/Cell and Cell Range Access"
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
|||
Line 7: | Line 7: | ||
|NextPage=Documentation/DevGuide/Spreadsheets/Merging Cell Ranges into a Single Cell | |NextPage=Documentation/DevGuide/Spreadsheets/Merging Cell Ranges into a Single Cell | ||
}} | }} | ||
− | {{DISPLAYTITLE:Cell and Cell Range Access}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Spreadsheets/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Cell and Cell Range Access}} | ||
<!--<idltopic>com.sun.star.sheet.SheetCellRange;com.sun.star.table.XCellRange;com.sun.star.sheet.XSheetCellRange</idltopic>--> | <!--<idltopic>com.sun.star.sheet.SheetCellRange;com.sun.star.table.XCellRange;com.sun.star.sheet.XSheetCellRange</idltopic>--> | ||
The interface <idl>com.sun.star.sheet.XSheetCellRange</idl> is derived from <idl>com.sun.star.table.XCellRange</idl>. It provides access to cells of the range and sub ranges, and is supported by the spreadsheet and sub-ranges of a spreadsheet. The methods in <idl>com.sun.star.sheet.XSheetCellRange</idl> are: | The interface <idl>com.sun.star.sheet.XSheetCellRange</idl> is derived from <idl>com.sun.star.table.XCellRange</idl>. It provides access to cells of the range and sub ranges, and is supported by the spreadsheet and sub-ranges of a spreadsheet. The methods in <idl>com.sun.star.sheet.XSheetCellRange</idl> are: |
Revision as of 10:23, 14 May 2009
The interface com.sun.star.sheet.XSheetCellRange is derived from com.sun.star.table.XCellRange. It provides access to cells of the range and sub ranges, and is supported by the spreadsheet and sub-ranges of a spreadsheet. The methods in com.sun.star.sheet.XSheetCellRange are:
com::sun::star::table::XCell getCellByPosition( [in] long nColumn, [in] long nRow) com::sun::star::table::XCellRange getCellRangeByPosition( [in] long nLeft, [in] long nTop, [in] long nRight, [in] long nBottom) com::sun::star::table::XCellRange getCellRangeByName ( [in] string aRange) com::sun::star::sheet::XSpreadsheet getSpreadsheet()
The interface com.sun.star.table.XCellRange provides methods to access cell ranges and single cells from a cell range.
Cells are retrieved by their position. Cell addresses consist of a row index and a column index. The index is zero-based, that is, the index 0 means the first row or column of the table.
Cell ranges are retrieved:
by position
- Addresses of cell ranges consist of indexes to the first and last row, and the first and last column. Range indexes are always zero-based, that is, the index 0 points to the first row or column of the table.
by name
- It is possible to address a cell range over its name in A1:B2 notation as it would appear in the application.
Additionally, XCellRange
contains the method getSpreadsheet()
that returns the com.sun.star.sheet.XSpreadsheet interface of the spreadsheet which contains the cell range.
// --- First cell in a cell range. --- com.sun.star.table.XCell xCell = xCellRange.getCellByPosition(0, 0); // --- Spreadsheet that contains the cell range. --- com.sun.star.sheet.XSpreadsheet xSheet = xCellRange.getSpreadsheet();
There are no methods to modify the contents of all cells of a cell range. Access to cell range formatting is supported. Refer to the chapter Formatting for additional details.
In the following example, xRange
is an existing cell range (a com.sun.star.table.XCellRange interface):
com.sun.star.beans.XPropertySet xPropSet = null; com.sun.star.table.XCellRange xCellRange = null; // *** Accessing a CELL RANGE *** // Accessing a cell range over its position. xCellRange = xRange.getCellRangeByPosition(2, 0, 3, 1); // Change properties of the range. xPropSet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xCellRange); xPropSet.setPropertyValue("CellBackColor", new Integer(0x8080FF)); // Accessing a cell range over its name. xCellRange = xRange.getCellRangeByName("C4:D5"); // Change properties of the range. xPropSet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, xCellRange); xPropSet.setPropertyValue("CellBackColor", new Integer(0xFFFF80));
Content on this page is licensed under the Public Documentation License (PDL). |