ChartDataWorkbook

Inheritance: java.lang.Object, com.aspose.slides.DomObject

All Implemented Interfaces: com.aspose.slides.IChartDataWorkbook

public class ChartDataWorkbook extends DomObject<ChartData> implements IChartDataWorkbook

Provides access to embedded Excel workbook

Methods

Method Description
getWorksheets() Gets a collection of worksheets.
getCellCollection(String formula, boolean skipHiddenCells) Gets the set of cells.
getCell(String worksheetName, int row, int column) Gets the cell that can be used for chart series or categories
getCell(int worksheetIndex, int row, int column) Gets the cell that can be used for chart series or categories
getCell(int worksheetIndex, String cellName) Gets the cell that can be used for chart series or categories
getCell(int worksheetIndex, String cellName, Object value) Gets the cell that can be used for chart series or categories
getCell(int worksheetIndex, int row, int column, Object value) Gets the cell that can be used for chart series or categories
clear(int sheetIndex) Clear all cells values on sheet
calculateFormulas() Calculates all formulas in the workbook and updates corresponding cells values.

getWorksheets()

public final IChartDataWorksheetCollection getWorksheets()

Gets a collection of worksheets.


Example:
 
 Presentation pres = new Presentation();
 try {
     IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 50, 50, 400, 500);
     IChartDataWorkbook workbook =  chart.getChartData().getChartDataWorkbook();
     for (IChartDataWorksheet worksheet : workbook.getWorksheets())
     {
         String worksheetName = worksheet.getName();
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: IChartDataWorksheetCollection

getCellCollection(String formula, boolean skipHiddenCells)

public final IChartCellCollection getCellCollection(String formula, boolean skipHiddenCells)

Gets the set of cells.

Parameters:

Parameter Type Description
formula java.lang.String Excel formula like “Sheet1!$A$2:$A$5”.
skipHiddenCells boolean If true then method returns collection without hidden cells.

Returns: IChartCellCollection

getCell(String worksheetName, int row, int column)

public final IChartDataCell getCell(String worksheetName, int row, int column)

Gets the cell that can be used for chart series or categories

Parameters:

Parameter Type Description
worksheetName java.lang.String Name of the worksheet.
row int The row.
column int The column.

Returns: IChartDataCell - Cell object

getCell(int worksheetIndex, int row, int column)

public final IChartDataCell getCell(int worksheetIndex, int row, int column)

Gets the cell that can be used for chart series or categories

Parameters:

Parameter Type Description
worksheetIndex int Index of the worksheet.
row int The row.
column int The column.

Returns: IChartDataCell - Cell object

getCell(int worksheetIndex, String cellName)

public final IChartDataCell getCell(int worksheetIndex, String cellName)

Gets the cell that can be used for chart series or categories

Parameters:

Parameter Type Description
worksheetIndex int Index of the worksheet.
cellName java.lang.String Name of the cell.

Returns: IChartDataCell - Cell object

getCell(int worksheetIndex, String cellName, Object value)

public final IChartDataCell getCell(int worksheetIndex, String cellName, Object value)

Gets the cell that can be used for chart series or categories

Parameters:

Parameter Type Description
worksheetIndex int Index of the worksheet.
cellName java.lang.String Name of the cell.
value java.lang.Object The value.

Returns: IChartDataCell - Cell object

getCell(int worksheetIndex, int row, int column, Object value)

public final IChartDataCell getCell(int worksheetIndex, int row, int column, Object value)

Gets the cell that can be used for chart series or categories

Parameters:

Parameter Type Description
worksheetIndex int Index of the worksheet.
row int The row.
column int The column.
value java.lang.Object The value.

Returns: IChartDataCell - Cell object

clear(int sheetIndex)

public final void clear(int sheetIndex)

Clear all cells values on sheet

Parameters:

Parameter Type Description
sheetIndex int Index of sheet

calculateFormulas()

public final void calculateFormulas()

Calculates all formulas in the workbook and updates corresponding cells values.


Example shows how to assign a formula to the cell and to calculate a value. The value of the "B4" cell is getting set to 5.
  
  Presentation pres = new Presentation();
  try {
      IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 100, 100, 300, 400);
      IChartDataWorkbook wb = chart.getChartData().getChartDataWorkbook();
      wb.getCell(0, "B2", 2);
      wb.getCell(0, "B3", 3);
      wb.getCell(0, "B4").setFormula("B2+B3");
      wb.calculateFormulas();
      ...
  } finally {
      if (pres != null) pres.dispose();
  }