ExcelDataWorkbook

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IExcelDataWorkbook

public class ExcelDataWorkbook implements IExcelDataWorkbook

Represents a workbook that provides access to Excel data for general use.

Constructors

ConstructorDescription
ExcelDataWorkbook(String filePath)Initializes a new instance using the specified file path.
ExcelDataWorkbook(InputStream stream)Initializes a new instance of the class using the provided stream.

Methods

MethodDescription
getCells(String formula, boolean skipHiddenCells)Retrieves a collection of cells from the workbook that match the specified formula.
getCell(int worksheetIndex, int row, int column)Retrieves a cell from the specified worksheet using its index and cell coordinates.
getCell(String worksheetName, int row, int column)Retrieves a cell from the specified worksheet using its name and cell coordinates.
getCell(int worksheetIndex, String cellName)Retrieves a cell from the specified worksheet using its index and Excel-style cell name (e.g., “B2”).
getCell(String worksheetName, String cellName)Retrieves a cell from the specified worksheet using Excel-style cell name (e.g., “B2”).
getChartsFromWorksheet(String worksheetName)Retrieves a dictionary containing the indexes and names of all charts in the specified worksheet of an Excel workbook.
getWorksheetNames()Retrieves the names of all worksheets contained in the Excel workbook.

ExcelDataWorkbook(String filePath)

public ExcelDataWorkbook(String filePath)

Initializes a new instance using the specified file path.

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe full path to the Excel workbook file.

ExcelDataWorkbook(InputStream stream)

public ExcelDataWorkbook(InputStream stream)

Initializes a new instance of the class using the provided stream.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamA stream containing the Excel workbook data.

getCells(String formula, boolean skipHiddenCells)

public final System.Collections.Generic.List<IExcelDataCell> getCells(String formula, boolean skipHiddenCells)

Retrieves a collection of cells from the workbook that match the specified formula.

Parameters:

ParameterTypeDescription
formulajava.lang.StringA formula or range expression (e.g., “Sheet1!A1:B3”) used to identify target cells.
skipHiddenCellsbooleanIf true, hidden cells (e.g., in hidden rows or columns) will be excluded from the result.

Returns: com.aspose.ms.System.Collections.Generic.List<com.aspose.slides.IExcelDataCell> - A read-only list of cells that match the specified formula.

getCell(int worksheetIndex, int row, int column)

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

Retrieves a cell from the specified worksheet using its index and cell coordinates.


Example:
 
 ExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 IExcelDataCell cell = wb.getCell(1, 1, 1);
 System.out.println(cell.getValue().toString());

Parameters:

ParameterTypeDescription
worksheetIndexintZero-based index of the worksheet.
rowintZero-based row index of the cell.
columnintZero-based column index of the cell.

Returns: IExcelDataCell - The cell at the specified location.

getCell(String worksheetName, int row, int column)

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

Retrieves a cell from the specified worksheet using its name and cell coordinates.


Example:
 
 ExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 IExcelDataCell cell = wb.getCell("Sheet1", 1, 1);
 System.out.println(cell.getValue().toString());

Parameters:

ParameterTypeDescription
worksheetNamejava.lang.StringThe name of the worksheet.
rowintZero-based row index of the cell.
columnintZero-based column index of the cell.

Returns: IExcelDataCell - The cell at the specified location.

getCell(int worksheetIndex, String cellName)

public final IExcelDataCell getCell(int worksheetIndex, String cellName)

Retrieves a cell from the specified worksheet using its index and Excel-style cell name (e.g., “B2”).


Example:
 
 ExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 IExcelDataCell cell = wb.getCell(1, "B2");
 System.out.println(cell.getValue().toString());

Parameters:

ParameterTypeDescription
worksheetIndexintZero-based index of the worksheet.
cellNamejava.lang.StringThe Excel-style cell reference (e.g., “A1”, “C5”).

Returns: IExcelDataCell - The cell at the specified location.

getCell(String worksheetName, String cellName)

public final IExcelDataCell getCell(String worksheetName, String cellName)

Retrieves a cell from the specified worksheet using Excel-style cell name (e.g., “B2”).


Example:
 
 ExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 IExcelDataCell cell = wb.getCell("Sheet1", "B2");
 System.out.println(cell.getValue().toString());

Parameters:

ParameterTypeDescription
worksheetNamejava.lang.StringThe name of the worksheet.
cellNamejava.lang.StringThe Excel-style cell reference (e.g., “A1”, “C5”).

Returns: IExcelDataCell - The cell at the specified location.

getChartsFromWorksheet(String worksheetName)

public final System.Collections.Generic.Dictionary<Integer,String> getChartsFromWorksheet(String worksheetName)

Retrieves a dictionary containing the indexes and names of all charts in the specified worksheet of an Excel workbook.


Example:
 
 ExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 Dictionary.Enumerator<Integer, String> sheetCharts = wb.getChartsFromWorksheet("worksheetName").iterator();
 while (sheetCharts.hasNext())
 {
     KeyValuePair<Integer, String> chart = sheetCharts.next();
     System.out.println(chart.getKey() + " : " + chart.getValue());
 }

Parameters:

ParameterTypeDescription
worksheetNamejava.lang.StringThe name of the worksheet to search for charts.

Returns: com.aspose.ms.System.Collections.Generic.Dictionary<java.lang.Integer,java.lang.String> - A dictionary where the key is the chart index and the value is the chart name.

getWorksheetNames()

public final System.Collections.Generic.List<String> getWorksheetNames()

Retrieves the names of all worksheets contained in the Excel workbook.


Example:
 
 IExcelDataWorkbook wb = new ExcelDataWorkbook(testFile);
 List<String> sheetNames = wb.getWorksheetNames();
 for (String name : sheetNames)
     System.out.println(name);

Returns: com.aspose.ms.System.Collections.Generic.List<java.lang.String> - A list of worksheet names