Documents > Cookbook >Cell Range

Get CellRange
You can get cell range by providing start and end index of the column and row,or just provide start and end address of the cell(if you are using the spreadsheet.)

        CellRange cellRange = table.getCellRangeByPosition(1, 0, 2, 0);
CellRange cellRangeAdd = table.getCellRangeByPosition("$E1","$E6");

Merge Text Table
The code below merges all of the selected cells into one:

        Table table1 = document.getTableByName("Table1");
CellRange cellrange = table1.getCellRangeByPosition(0, 0, table1.getColumnCount()-1, table1.getRowCount()-1);

Merge Text Column
The code below shows how to merge the cells of the first column into one :

            table1 = document.getTableByName("Table1");
CellRange firstColumn = table1.getCellRangeByPosition(0, 0, 0, table1.getRowCount()-1);

Merge Text Row
The code below shows how to merge the cells of the first 2 rows into one :

        table1 = document.getTableByName("Table1");
int rowCount = table1.getRowCount();
CellRange firstTwoRow = table1.getCellRangeByPosition(0, 0, table1.getColumnCount()-1, 1);

Merge SpreadSheet
Merge a spreadsheet's cell is the same as text document.Especially,when getting the cell range of spreadsheet,you can use special address instead of index.

        Table sheet1 = document.getTableByName("Sheet1");
CellRange cellRange2 = sheet1.getCellRangeByPosition("$E1","$E6");

Powered by the Apache CMS.

Apache "ODF Toolkit" is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Copyright © 2011 The Apache Software Foundation Licensed under the Apache License, Version 2.0. Contact Us
Apache and the Apache feather logos are trademarks of The Apache Software Foundation.
Other names appearing on the site may be trademarks of their respective owners.