CellPosition Class
The position of a cell in chart data, specified by zero-based row and column indexes.
Declaration
public final class CellPosition extends Struct<CellPosition>
Remarks
Pass CellPosition values to a ChartDataReference constructor (for example, ChartDataReference(topPosition, bottomPosition)) to specify a cell range by row and column indexes. ChartDataReference.getTopLeftPosition() and ChartDataReference.getBottomRightPosition() methods return CellPosition values.
Row index 0 corresponds to row 1, and column index 0 corresponds to column A. For example, cell C5 has row index 4 and column index 2.
Example: Bind a Series to Cell Ranges Specified by Indexes
The following code snippet binds line series values and arguments to cell ranges specified by zero-based row and column indexes:
import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
public class Main {
public static void main(String[] args) throws Exception {
try (Presentation presentation = new Presentation()) {
// Add a blank slide.
presentation.getSlides().clear();
Slide slide = new Slide(SlideLayoutType.BLANK);
presentation.getSlides().add(slide);
// Insert a chart that fills the slide.
Chart chart = new Chart();
chart.setWidth(presentation.getSlideSize().getWidth());
chart.setHeight(presentation.getSlideSize().getHeight());
slide.getShapes().add(chart);
// Populate values in column A and arguments in column B.
ChartData data = chart.getData();
double[] values = { 120, 95, 140, 100, 80 };
for (int row = 0; row < values.length; row++) {
data.get("A" + (row + 1)).setNumericValue(values[row]);
data.get("B" + (row + 1)).setNumericValue((row + 1) * 10);
}
// Bind a line series to cell ranges specified by zero-based row and column indexes.
LineSeries series = new LineSeries();
series.setValues(new ChartDataReference(new CellPosition(0, 0), new CellPosition(4, 0)));
series.setArguments(new ChartDataReference(new CellPosition(0, 1), new CellPosition(4, 1)));
chart.getSeries().add(series);
// Save the presentation.
Files.createDirectories(Path.of("output"));
try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
presentation.save(output);
}
}
}
}
The following screenshot illustrates the result:

Inherited Members
Inheritance
Constructors
CellPosition() Constructor
Initializes a new instance of the CellPosition class.
Declaration
public CellPosition()
Remarks
The new cell position points to cell A1 (column index 0 and row index 0).
CellPosition(int rowIndex, int columnIndex) Constructor
Initializes a new instance of the CellPosition class with the specified row and column indexes.
Declaration
public CellPosition(int rowIndex, int columnIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| rowIndex | int | The zero-based row index. |
| columnIndex | int | The zero-based column index. |
Methods
equals(Object obj) Method
Returns whether the specified object equals this cell position.
Declaration
public boolean equals(Object obj)
Parameters
| Name | Type | Description |
|---|---|---|
| obj | Object | The object to compare. |
Returns
| Type | Description |
|---|---|
| boolean |
|
getColumnIndex() Method
Returns the zero-based column index of the cell.
Declaration
public int getColumnIndex()
Returns
| Type | Description |
|---|---|
| int | The zero-based column index. |
getRowIndex() Method
Returns the zero-based row index of the cell.
Declaration
public int getRowIndex()
Returns
| Type | Description |
|---|---|
| int | The zero-based row index. |
hashCode() Method
Returns the hash code of the cell position.
Declaration
public int hashCode()
Returns
| Type | Description |
|---|---|
| int | The hash code. |