public class GridCells
extends java.lang.Object
implements java.lang.Iterable
GridCell objects.| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
cellIndexToName(int row,
int column)
Gets cell name according to its row and column indexes.
|
static void |
cellNameToIndex(java.lang.String cellName,
int row,
int column)
Gets the cell row and column indexes according to its name
|
GridCell |
checkCell(int row,
int column)
Gets the
GridCell element or null at the specified cell row index and column index. |
GridColumn |
checkColumn(int col)
Gets the
GridColumn element or null at the specified column index. |
GridRow |
checkRow(int i)
Gets the
GridRow element or null at the specified cell row index. |
void |
clear()
Clear all cells in the collection.
|
void |
clearContents(GridCellArea range)
Clears contents of a range.
|
void |
clearContents(int startRow,
int startColumn,
int endRow,
int endColumn)
Clears contents of a range.
|
void |
clearFormats(GridCellArea range)
Clears formatting of a range.
|
void |
clearFormats(int startRow,
int startColumn,
int endRow,
int endColumn)
Clears formatting of a range.
|
void |
clearRange(GridCellArea range)
Clears contents and formatting of a range.
|
void |
clearRange(int startRow,
int startColumn,
int endRow,
int endColumn)
Clears contents and formatting of a range.
|
static java.lang.String |
columnIndexToName(int column)
Gets column name according to column index.
|
static int |
columnNameToIndex(java.lang.String columnName)
Gets column index according to column name.
|
void |
copyColumn(GridCells sourceCells,
int sourceColumnIndex,
int destinationColumnIndex)
Copies data and formattings of a whole column.
|
void |
copyColumns(GridCells sourceCells,
int sourceColumnIndex,
int destinationColumnIndex,
int columnNumber)
Copies data and formattings of a whole column.
|
void |
copyRow(GridCells sourceCells,
int sourceRowIndex,
int destinationRowIndex)
Copies data and formattings of a whole row.
|
void |
copyRows(GridCells sourceCells,
int sourceRowIndex,
int destinationRowIndex,
int rowNumber)
Copies data and formattings of some whole rows.
|
void |
deleteBlankColumns()
Delete all blank columns which do not contain any data.
|
void |
deleteBlankRows()
Delete all blank rows which do not contain any data.
|
void |
deleteColumn(int columnIndex)
Deletes a column.
|
void |
deleteColumn(int columnIndex,
boolean updateReference)
Deletes a column.
|
void |
deleteColumns(int columnIndex,
int totalColumns,
boolean updateReference)
Deletes several columns.
|
void |
deleteRange(int startRow,
int startColumn,
int endRow,
int endColumn,
int shiftType)
Deletes a range of cells and shift cells according to the shift option.
|
void |
deleteRow(int rowIndex)
Deletes a row.
|
boolean |
deleteRows(int rowIndex,
int totalRows)
Deletes several rows.
|
boolean |
deleteRows(int rowIndex,
int totalRows,
boolean updateReference)
Deletes multiple rows in the worksheet.
|
java.lang.Object[][] |
exportArray(int firstRow,
int firstColumn,
int totalRows,
int totalColumns)
Exports data in the
GridCells collection to a two-dimension array object. |
GridCell |
get(int row,
int column)
Gets the
GridCell element at the specified cell row index and column index. |
GridCell |
get(java.lang.String cellName)
Gets the
GridCell element at the specified cell name. |
GridCell |
getCell(int row,
int column)
Gets the
GridCell element at the specified cell row index and column index. |
GridColumnCollection |
getColumns()
Gets the collection of
GridColumn objects that represents the individual columns in this worksheet. |
double |
getColumnWidth(int column)
Gets the width of the specified column
|
double |
getColumnWidthInch(int column)
Gets the width of the specified column, in units of inches.
|
int |
getColumnWidthPixel(int column)
Gets the width of the specified column, in units of pixel.
|
int |
getCount()
Gets the number of cells.
|
GridCell |
getFirstCell()
Gets the first cell in this worksheet.
|
GridCell |
getLastCell()
Gets the last cell in this worksheet.
|
int |
getMaxColumn()
Maximum column index of cell which contains data or style.
|
int |
getMaxDataColumn()
Maximum column index of cell which contains data.
|
int |
getMaxDataRow()
Maximum row index of cell which contains data.
|
int |
getMaxRow()
Maximum row index of cell which contains data or style.
|
java.util.ArrayList |
getMergedCells()
Gets the collection of merged cells.
|
int |
getMinColumn()
Minimum column index of those cells that have been instantiated in the collection(does not include the column
where style is defined for the whole column but no cell has been instantiated in it).
|
int |
getMinDataColumn()
Minimum column index of cell which contains data.
|
int |
getMinDataRow()
Minimum row index of cell which contains data.
|
int |
getMinRow()
Minimum row index of cell which contains data or style.
|
GridRow |
getRow(int i)
Gets the
GridRow element or at the specified cell row index. |
java.util.Iterator |
getRowEnumerator()
Gets the rows enumerator
|
double |
getRowHeight(int row)
Gets the height of a specified row.
|
double |
getRowHeightInch(int row)
Gets the height of a specified row in unit of inches.
|
int |
getRowHeightPixel(int row)
Gets the height of a specified row in unit of pixel.
|
int |
getRowOutlineLevel(int rowIndex)
Gets the outline level of the row.
|
GridRowCollection |
getRows()
Gets the collection of
GridRow objects that represents the individual rows in this worksheet. |
double |
getStandardHeight()
Gets the default row height in this worksheet,in unit of points.
|
int |
getStandardHeightPixels()
Gets the default row height in this worksheet,in unit of pixels.
|
double |
getStandardWidth()
Gets the default column width in the worksheet,in unit of characters.
|
double |
getStandardWidthInch()
Gets the default column width in the worksheet, in unit of inches.
|
int |
getStandardWidthPixels()
Gets the default column width in the worksheet, in unit of pixels.
|
int |
getViewColumnWidthPixel(int column)
Get the width in different view type.
|
void |
groupColumns(int firstIndex,
int lastIndex)
Groups columns.
|
void |
groupColumns(int firstIndex,
int lastIndex,
boolean isHidden)
Groups columns.
|
void |
groupRows(int firstIndex,
int lastIndex)
Groups rows.
|
void |
hideColumn(int column)
Hides a column.
|
void |
hideRow(int row)
Hides a row.
|
void |
insertColumn(int columnIndex)
Inserts a new column into the worksheet.
|
void |
insertColumn(int columnIndex,
boolean updateReference)
Inserts a new column into the worksheet.
|
void |
insertColumns(int columnIndex,
int totalColumns)
Inserts some columns into the worksheet.
|
void |
insertColumns(int columnIndex,
int totalColumns,
boolean updateReference)
Inserts some columns into the worksheet.
|
void |
insertRange(GridCellArea area,
int shiftType)
Inserts a range of cells and shift cells according to the shift option.
|
void |
insertRange(GridCellArea area,
int shiftNumber,
int shiftType,
boolean updateReference)
Inserts a range of cells and shift cells according to the shift option.
|
void |
insertRow(int rowIndex)
Inserts a new row into the worksheet.
|
void |
insertRows(int rowIndex,
int totalRows)
Inserts multiple rows into the worksheet.
|
void |
insertRows(int rowIndex,
int totalRows,
boolean updateReference)
Inserts multiple rows into the worksheet.
|
boolean |
isBlankColumn(int columnIndex)
Checks whether given column is blank(does not contain any data).
|
boolean |
isColumnHidden(int columnIndex)
Checks whether a column at given index is hidden.
|
boolean |
isRowHidden(int rowIndex)
Checks whether a row at given index is hidden.
|
java.util.Iterator |
iterator()
Gets the rows enumerator
|
void |
merge(int firstRow,
int firstColumn,
int totalRows,
int totalColumns)
Merges a specified range of cells into a single cell.
|
void |
moveRange(GridCellArea sourceArea,
int destRow,
int destColumn)
Moves the range.
|
void |
removeDuplicates(int startRow,
int startColumn,
int endRow,
int endColumn)
Remove duplicate values in the range.
|
void |
removeFormulas()
Removes all formula and replaces with the value of the formula.
|
void |
setBorders(int firstRow,
int firstColumn,
int rowNumber,
int columnNumber,
int position,
WebBorderStyle borderStyle)
Sets borders for a cells range.
|
void |
setColumnWidth(int column,
double width)
Sets the width of the specified column.
|
void |
setColumnWidthInch(int column,
double inches)
Sets column width in unit of inches.
|
void |
setColumnWidthPixel(int column,
int pixel)
Sets column width in unit of pixels.
|
void |
setRowHeight(int row,
double height)
Sets the height of the specified row.
|
void |
setRowHeightInch(int row,
double inches)
Sets row height in unit of inches.
|
void |
setRowHeightPixel(int row,
int pixels)
Sets row height in unit of pixels.
|
void |
setRowOutlineLevel(int rowIndex,
int outlineLevel)
Sets the outline level of the row.
|
void |
setStandardHeight(double value)
Sets the default row height in this worksheet,in unit of points.
|
void |
setStandardHeightPixels(int value)
Sets the default row height in this worksheet,in unit of pixels.
|
void |
setStandardWidth(double value)
Sets the default column width in the worksheet,in unit of characters.
|
void |
setStandardWidthInch(double value)
Sets the default column width in the worksheet, in unit of inches.
|
void |
setStandardWidthPixels(int value)
Sets the default column width in the worksheet, in unit of pixels.
|
void |
setStyle(int firstRow,
int firstColumn,
int rowNumber,
int columnNumber,
GridTableItemStyle style)
Sets the style to a specified range of cells.
|
void |
setStyle(java.lang.String cellRange,
GridTableItemStyle style)
Sets the style to a specified range of cells.
|
void |
sort(int startRow,
int startColumn,
int rows,
int columns,
int[] indexes,
int[] orders,
int orientation,
boolean isCaseSensitive)
Sorts the datas ascend/decend top to bottom in a range of a Worksheet by specified column index.
|
void |
sort(int startRow,
int startColumn,
int rows,
int columns,
int index,
boolean isAsending,
boolean isCaseSensitive,
boolean islefttoright)
Sorts the datas ascend/decend top to bottom in a range of a Worksheet by specified column index.
|
void |
ungroupColumns(int firstIndex,
int lastIndex)
Ungroups columns.
|
void |
ungroupRows(int firstIndex,
int lastIndex)
Ungroups rows.
|
void |
unhideColumn(int column,
double width)
Unhides a column
|
void |
unhideRow(int row)
Unhides a row.
|
void |
unMerge(int firstRow,
int firstColumn,
int totalRows,
int totalColumns)
Unmerges a specified range of merged cells.
|
public void merge(int firstRow,
int firstColumn,
int totalRows,
int totalColumns)
Remarks
Reference the merged cell via the address of the upper-left cell in the range.firstRow - First row of this range(zero based)firstColumn - First column of this range(zero based)totalRows - Number of rows(one based)totalColumns - Number of columns(one based)public java.util.Iterator getRowEnumerator()
public GridRowCollection getRows()
GridRow objects that represents the individual rows in this worksheet.public GridCell getCell(int row, int column)
GridCell element at the specified cell row index and column index.row - Row indexcolumn - Column indexpublic GridCell checkCell(int row, int column)
GridCell element or null at the specified cell row index and column index.row - Row indexcolumn - Column indexpublic GridRow getRow(int i)
GridRow element or at the specified cell row index.i - Row indexpublic GridRow checkRow(int i)
GridRow element or null at the specified cell row index.i - Row indexGridRow object If the row object does exist, otherwise returns null.public GridCell get(int row, int column)
GridCell element at the specified cell row index and column index.
Example
GridWeb GridWeb1 = new GridWeb();
GridCells cells = GridWeb1.getWorkSheets().get(0).getCells();
//Gets the cell at "A1"
GridCell cell = cells.get(0, 0);
row - Row index.column - Column index.GridCell object.public GridCell get(java.lang.String cellName)
GridCell element at the specified cell name.
Example
GridWeb GridWeb1 = new GridWeb();
GridCells cells = GridWeb1.getWorkSheets().get(0).getCells();
GridCell cell = cells.get("A1"); //Gets the cell at "A1"
cellName - Cell name,including its column letter and row number, for example A5.GridCell objectpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterablepublic int getCount()
public GridColumnCollection getColumns()
GridColumn objects that represents the individual columns in this worksheet.public GridColumn checkColumn(int col)
GridColumn element or null at the specified column index.col - The column index.public boolean isRowHidden(int rowIndex)
rowIndex - row indexpublic boolean isColumnHidden(int columnIndex)
columnIndex - column indexpublic double getStandardWidthInch()
public void setStandardWidthInch(double value)
public int getStandardWidthPixels()
public void setStandardWidthPixels(int value)
public double getStandardWidth()
public void setStandardWidth(double value)
public double getStandardHeight()
public void setStandardHeight(double value)
public int getStandardHeightPixels()
public void setStandardHeightPixels(int value)
public void unMerge(int firstRow,
int firstColumn,
int totalRows,
int totalColumns)
firstRow - First row of this range(zero based)firstColumn - First column of this range(zero based)totalRows - Number of rows(one based)totalColumns - Number of columns(one based)public java.util.ArrayList getMergedCells()
Remarks
In this collection, each item is aGridCellArea structure which represents an area of merged cells.public void hideRow(int row)
row - Row index.public void setRowHeight(int row,
double height)
Remarks
To hide a row, sets row height to zero.row - Row index.height - Height of row.In unit of point It should be between 0 and 409.5.public void setRowHeightPixel(int row,
int pixels)
row - Row index.pixels - Number of pixels.public void setRowHeightInch(int row,
double inches)
row - Row index.inches - Number of inches.It should be between 0 and 409.5/72.public double getRowHeight(int row)
row - Row indexpublic int getRowHeightPixel(int row)
row - Row indexpublic double getRowHeightInch(int row)
row - Row indexpublic void setColumnWidth(int column,
double width)
Remarks
To hide a column, sets column width to zero.column - Column index.width - Width of column.Column width must be between 0 and 255.public void setColumnWidthPixel(int column,
int pixel)
column - Column index.pixel - Number of pixels.public void setColumnWidthInch(int column,
double inches)
column - Column index.inches - Number of inches.public int getViewColumnWidthPixel(int column)
column - The column index.public double getColumnWidth(int column)
column - Column indexpublic int getColumnWidthPixel(int column)
column - Column indexpublic double getColumnWidthInch(int column)
column - Column indexpublic void unhideRow(int row)
row - Row index.public void hideColumn(int column)
column - Column index.public void unhideColumn(int column,
double width)
column - Column index.width - Column width..Column width must be between 0 and 255public int getMinRow()
public int getMinDataRow()
public int getMinDataColumn()
Remarks
-1 will be returned if there is no cell which contains data. This property needs to iterate and check all cells in a worksheet, so it is a time-consumed progress and should not be invoked repeatedly.public int getMinColumn()
public int getMaxDataRow()
Remarks
Return -1 if there is no cell which contains data.public int getMaxRow()
Remarks
Return -1 if there is no cell whiche contains data or style in the worksheet.public int getMaxDataColumn()
Remarks
-1 will be returned if there is no cell which contains data. This property needs to iterate and check all cells in a worksheet, so it is a time-consumed progress and should not be invoked repeatedly.public int getMaxColumn()
Remarks
Return -1 if ther is not cell.public void copyColumn(GridCells sourceCells, int sourceColumnIndex, int destinationColumnIndex)
sourceCells - Source Cells object contains data and formattings to copy.sourceColumnIndex - Source column index.destinationColumnIndex - Destination column index.public void copyColumns(GridCells sourceCells, int sourceColumnIndex, int destinationColumnIndex, int columnNumber)
sourceCells - Source Cells object contains data and formattings to copy.sourceColumnIndex - Source column index.destinationColumnIndex - Destination column index.columnNumber - The copied column number.public void copyRow(GridCells sourceCells, int sourceRowIndex, int destinationRowIndex)
sourceCells - Source Cells object contains data and formattings to copy.sourceRowIndex - Source row index.destinationRowIndex - Destination row index.public void copyRows(GridCells sourceCells, int sourceRowIndex, int destinationRowIndex, int rowNumber)
sourceCells - Source Cells object contains data and formattings to copy.sourceRowIndex - Source row index.destinationRowIndex - Destination row index.rowNumber - The copied row number.public void ungroupColumns(int firstIndex,
int lastIndex)
firstIndex - The first column index to be ungrouped.lastIndex - The last column index to be ungrouped.public void groupColumns(int firstIndex,
int lastIndex)
firstIndex - The first column index to be grouped.lastIndex - The last column index to be grouped.public void groupColumns(int firstIndex,
int lastIndex,
boolean isHidden)
firstIndex - The first column index to be grouped.lastIndex - The last column index to be grouped.isHidden - Specifies if the grouped columns are hidden.public void ungroupRows(int firstIndex,
int lastIndex)
Remarks
Only removes outter group info.firstIndex - The first row index to be ungrouped.lastIndex - The last row index to be ungrouped.public void groupRows(int firstIndex,
int lastIndex)
firstIndex - The first row index to be grouped.lastIndex - The last row index to be grouped.public void deleteColumn(int columnIndex)
columnIndex - Column index.public void deleteColumn(int columnIndex,
boolean updateReference)
columnIndex - Column index.updateReference - Indicates if update references in other worksheets.public void insertColumns(int columnIndex,
int totalColumns)
columnIndex - Column index.totalColumns - The number of columns.public void insertColumns(int columnIndex,
int totalColumns,
boolean updateReference)
columnIndex - Column index.totalColumns - The number of columns.updateReference - Indicates if references in other worksheets will be updated.public void deleteColumns(int columnIndex,
int totalColumns,
boolean updateReference)
columnIndex - Column index.totalColumns - Number of columns to be deleted.updateReference - Indicates if update references in other worksheets.public void insertColumn(int columnIndex,
boolean updateReference)
columnIndex - Column index.updateReference - Indicates if references in other worksheets will be updated.public void insertColumn(int columnIndex)
columnIndex - Column index.public boolean deleteRows(int rowIndex,
int totalRows)
Remarks
If the deleted range contains the top part(not whole) of the table(ListObject), the ranged could not be deleted and nothing will be done.It works as MS Excel.rowIndex - The first row index to be deleted.totalRows - Number of rows to be deleted.public boolean deleteRows(int rowIndex,
int totalRows,
boolean updateReference)
rowIndex - Row index.totalRows - Number of rows to be deleted.updateReference - Indicates if update references in other worksheets.public void deleteRow(int rowIndex)
rowIndex - Row index.public void insertRows(int rowIndex,
int totalRows,
boolean updateReference)
rowIndex - Row index.totalRows - Number of rows to be inserted.updateReference - Indicates if references in other worksheets will be updated.public void insertRows(int rowIndex,
int totalRows)
rowIndex - Row index.totalRows - Number of rows to be inserted.public void insertRow(int rowIndex)
rowIndex - Row index.public void deleteBlankColumns()
public boolean isBlankColumn(int columnIndex)
columnIndex - the column indexpublic void deleteBlankRows()
public void clearRange(int startRow,
int startColumn,
int endRow,
int endColumn)
startRow - Start row index.startColumn - Start column index.endRow - End row index.endColumn - End column index.public void clearRange(GridCellArea range)
range - Range to be cleared.public void clearContents(int startRow,
int startColumn,
int endRow,
int endColumn)
startRow - Start row index.startColumn - Start column index.endRow - End row index.endColumn - End column index.public void clearContents(GridCellArea range)
range - Range to be cleared.public void clearFormats(int startRow,
int startColumn,
int endRow,
int endColumn)
startRow - Start row index.startColumn - Start column index.endRow - End row index.endColumn - End column index.public void clearFormats(GridCellArea range)
range - Range to be cleared.public void setStyle(int firstRow,
int firstColumn,
int rowNumber,
int columnNumber,
GridTableItemStyle style)
firstRow - First row of this range(zero based)firstColumn - First column of this range(zero based)rowNumber - Number of rows(one based)columnNumber - Number of columns(one based)style - The style object to be setpublic void setStyle(java.lang.String cellRange,
GridTableItemStyle style)
cellRange - The range of cells' names, like "A1:D6"style - The style object to be setpublic GridCell getFirstCell()
Remarks
Returns null if there is no data in the worksheet.public GridCell getLastCell()
Remarks
Returns null if there is no data in the worksheet.public void removeFormulas()
public void sort(int startRow,
int startColumn,
int rows,
int columns,
int index,
boolean isAsending,
boolean isCaseSensitive,
boolean islefttoright)
Example
GridWeb GridWeb1 = new GridWeb();
GridWeb1.getWorkSheets().get(0).getCells().sort(1,0,25,6,3,true,true,false);
startRow - The row number of the first cell to sort.startColumn - The column number of the first cell to sort.rows - Number of rows to be imported.columns - Number of columns to be imported.index - The column index that specifis the sort column.
if the Orientation is top to bottom ,it stand for the column index that specifis the sort column.
if the Orientation is from left to right,it stand for the row index that specifis the sort row.isAsending - whether the sorting order is asending .isCaseSensitive - whether the sort is casesensitive .islefttoright - whether the sort orientation is from left to rightpublic void sort(int startRow,
int startColumn,
int rows,
int columns,
int[] indexes,
int[] orders,
int orientation,
boolean isCaseSensitive)
startRow - The row number of the first cell to sort.startColumn - The column number of the first cell to sort.rows - Number of rows to be imported.columns - Number of columns to be imported.indexes - The column index array that specifis the sort column.
if the Orientation is top to bottom ,it stand for the column index that specifis the sort column.
if the Orientation is from left to right,it stand for the row index that specifis the sort row.orders - SortByOrder. the the sorting order array .orientation - SortOrientation. sorting orientationisCaseSensitive - whether the sort is casesensitive .public void clear()
public void moveRange(GridCellArea sourceArea, int destRow, int destColumn)
sourceArea - The range which should be moved.destRow - The dest row.destColumn - The dest column.public void insertRange(GridCellArea area, int shiftType)
area - Shift area.shiftType - GridShiftType. Shift cells option.public void insertRange(GridCellArea area, int shiftNumber, int shiftType, boolean updateReference)
area - Shift area.shiftNumber - Number of rows or columns to be inserted.shiftType - GridShiftType. Shift cells option.updateReference - Indicates if update references in other worksheets.public void deleteRange(int startRow,
int startColumn,
int endRow,
int endColumn,
int shiftType)
startRow - Start row index.startColumn - Start column index.endRow - End row index.endColumn - End column index.shiftType - GridShiftType. Shift cells option.public void removeDuplicates(int startRow,
int startColumn,
int endRow,
int endColumn)
startRow - The start row.startColumn - The start columnendRow - The end row index.endColumn - The end column index.public int getRowOutlineLevel(int rowIndex)
rowIndex - row index.public void setRowOutlineLevel(int rowIndex,
int outlineLevel)
rowIndex - row index.outlineLevel - outline level.public static int columnNameToIndex(java.lang.String columnName)
columnName - Column name.public static java.lang.String columnIndexToName(int column)
column - Column index.public static java.lang.String cellIndexToName(int row,
int column)
row - Row index.column - Column index.public static void cellNameToIndex(java.lang.String cellName,
int row,
int column)
cellName - Name of cell.row - Output row indexcolumn - Output column indexpublic void setBorders(int firstRow,
int firstColumn,
int rowNumber,
int columnNumber,
int position,
WebBorderStyle borderStyle)
Example
GridWeb GridWeb1 = new GridWeb();
WebBorderStyle borderStyle1 = new WebBorderStyle();
GridWeb1.getWorkSheets().get(0).getCells().setBorders(0, 0, 5, 8, SetBorderPosition.OUTLINE, borderStyle1);
firstRow - The first row number of the range(zero based).firstColumn - The first column number of the range(zero based).rowNumber - The rows number.columnNumber - The columns number.position - SetBorderPosition. The border position.borderStyle - The border style.public java.lang.Object[][] exportArray(int firstRow,
int firstColumn,
int totalRows,
int totalColumns)
GridCells collection to a two-dimension array object.firstRow - The row number of the first cell to export out.firstColumn - The column number of the first cell to export out.totalRows - Number of rows to be exportedtotalColumns - Number of columns to be exportedSee Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.