com.aspose.cells
Class Row

java.lang.Object
    extended by com.aspose.cells.Row
All Implemented Interfaces:
java.lang.Iterable

public class Row 
extends java.lang.Object

Represents a single row in a worksheet.

Example:

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Style style = workbook.createStyle();

//Setting the background color to Blue
style.setBackgroundColor(Color.getBlue());

//Setting the foreground color to Red
style.setForegroundColor(Color.getRed());

//setting Background Pattern
style.setPattern(BackgroundType.DIAGONAL_STRIPE);

//New Style Flag
StyleFlag styleFlag = new StyleFlag();

//Set All Styles
styleFlag.setAll(true);

 //Get first row
Row row = worksheet.getCells().getRows().get(0);
 //Apply Style to first row
row.applyStyle(style, styleFlag);

//Saving the Excel file
workbook.save("book1.xls");


Property Getters/Setters Summary
CellgetFirstCell()
           Gets the first cell object in the row.
CellgetFirstDataCell()
           Gets the first non-blank cell in the row.
bytegetGroupLevel()
voidsetGroupLevel(byte)
           Gets the group level of the row.
booleanhasCustomStyle()
           Indicates whether this row has custom style settings(different from the default one inherited from workbook).
doublegetHeight()
voidsetHeight(double)
           Gets and sets the row height in unit of Points.
intgetIndex()
           Gets the index of this row.
booleanisBlank()
           Indicates whether the row contains any data
booleanisCollapsed()
voidsetCollapsed(boolean)
           whether the row is collapsed
booleanisHeightMatched()
voidsetHeightMatched(boolean)
           Indicates that row height and default font height matches.
booleanisHidden()
voidsetHidden(boolean)
           Indicates whether the row is hidden.
CellgetLastCell()
           Gets the last cell object in the row.
CellgetLastDataCell()
           Gets the last non-blank cell in the row.
Cellget(int)
           Gets the cell.
 
Method Summary
voidapplyStyle(Style style, StyleFlag flag)
           Applies formats for a whole row.
voidcopySettings(Row source, boolean checkStyle)
           Copy settings of row, such as style, height, visibility, ...etc.
booleanequals(Row row)
           Checks whether this object refers to the same row with another row object.
booleanequals(java.lang.Object obj)
           Checks whether this object refers to the same row with another.
CellgetCellByIndex(int index)
           Get the cell by specific index in the list.
CellgetCellOrNull(int column)
           Gets the cell or null in the specific index.
StylegetStyle()
           Gets the style of this row.
java.util.Iteratoriterator()
           Gets the cells enumerator
voidsetStyle(Style style)
           Sets the style of this row.
 

Property Getters/Setters Detail

isBlank

public boolean isBlank()
Indicates whether the row contains any data

isCollapsed/setCollapsed

public boolean isCollapsed() / public void setCollapsed(boolean value)
whether the row is collapsed

setCollapsed

public void setCollapsed(boolean value)
whether the row is collapsed

getHeight/setHeight

public double getHeight() / public void setHeight(double value)
Gets and sets the row height in unit of Points.

setHeight

public void setHeight(double value)
Gets and sets the row height in unit of Points.

isHidden/setHidden

public boolean isHidden() / public void setHidden(boolean value)
Indicates whether the row is hidden.

setHidden

public void setHidden(boolean value)
Indicates whether the row is hidden.

getIndex

public int getIndex()
Gets the index of this row.

getGroupLevel/setGroupLevel

public byte getGroupLevel() / public void setGroupLevel(byte value)
Gets the group level of the row.

setGroupLevel

public void setGroupLevel(byte value)
Gets the group level of the row.

isHeightMatched/setHeightMatched

public boolean isHeightMatched() / public void setHeightMatched(boolean value)
Indicates that row height and default font height matches.

setHeightMatched

public void setHeightMatched(boolean value)
Indicates that row height and default font height matches.

hasCustomStyle

public boolean hasCustomStyle()
Indicates whether this row has custom style settings(different from the default one inherited from workbook).

getFirstCell

public Cell getFirstCell()
Gets the first cell object in the row.

getFirstDataCell

public Cell getFirstDataCell()
Gets the first non-blank cell in the row.

getLastCell

public Cell getLastCell()
Gets the last cell object in the row.

getLastDataCell

public Cell getLastDataCell()
Gets the last non-blank cell in the row.

get

public Cell get(int column)
Gets the cell.
Parameters:
column - The column index
Returns:

Method Detail

getCellByIndex

public Cell getCellByIndex(int index)
Get the cell by specific index in the list. NOTE: This member is now obsolete. Instead, please use Row.GetEnumerator() method to iterate all cells in this row. This property will be removed 12 months later since February 2015. Aspose apologizes for any inconvenience you may have experienced.
Parameters:
index - The position.
Returns:
The Cell object.

iterator

public java.util.Iterator iterator()
Gets the cells enumerator
Returns:
The cells enumerator

Example:

Workbook workbook = new Workbook("template.xlsx");
   Cells cells = workbook.getWorksheets().get(0).getCells();
   
   Iterator en = cells.getRows().get(1).iterator();
   while (en.hasNext())
   {
       Cell cell = (Cell)en.next();
       System.out.println(cell.getName() + ": " + cell.getValue());
   }

getCellOrNull

public Cell getCellOrNull(int column)
Gets the cell or null in the specific index.
Parameters:
column - The column index
Returns:
Returns the cell object if the cell exists. Or returns null if the cell object does not exist.

getStyle

public Style getStyle()
Gets the style of this row. Modifying the returned style object directly takes no effect for this row or any cells in this row. You have to call applyStyle(com.aspose.cells.Style, com.aspose.cells.StyleFlag) or setStyle(com.aspose.cells.Style) method to apply the change to this row.
Row's style is the style which will be inherited by cells in this row(those cells that have no custom style settings, such as existing cells that have not been set style explicitly, or those that have not been instantiated)

setStyle

public void setStyle(Style style)
Sets the style of this row. This method only sets the given style as the default style for this row, without changing the style settings for existing cells in this row. To update style settings of existing cells to the specified style at the same time, please use applyStyle(com.aspose.cells.Style, com.aspose.cells.StyleFlag)
Parameters:
style - the style to be used as the default style for cells in this row.

copySettings

public void copySettings(Row source, boolean checkStyle)
Copy settings of row, such as style, height, visibility, ...etc.
Parameters:
source - the source row whose settings will be copied to this one
checkStyle - whether check and gather style. Only takes effect and be needed when two row objects belong to different workbook and the styles of two workbooks are different.

applyStyle

public void applyStyle(Style style, StyleFlag flag)
Applies formats for a whole row.
Parameters:
style - The style object which will be applied.
flag - Flags which indicates applied formatting properties.

equals

public boolean equals(java.lang.Object obj)
Checks whether this object refers to the same row with another.
Parameters:
obj - another object
Returns:
true if two objects refers to the same row.

equals

public boolean equals(Row row)
Checks whether this object refers to the same row with another row object.
Parameters:
row - another row object
Returns:
true if two row objects refers to the same row.

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.