AddTableFromWorkbook

AddTableFromWorkbook(IShapeCollection, float, float, IExcelDataWorkbook, string, string)

Retrieves a table from the specified Excel workbook and adds it to the end of the given shape collection at the specified coordinates.

public static ITable AddTableFromWorkbook(IShapeCollection shapes, float x, float y, 
    IExcelDataWorkbook workbook, string worksheetName, string cellRange)
ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the table will be added.
xSingleThe X coordinate for positioning the table.
ySingleThe Y coordinate for positioning the table.
workbookIExcelDataWorkbookThe Excel workbook.
worksheetNameStringThe name of the worksheet that contains the table.
cellRangeStringThe cell range that defines the table (for example, “A1:D10”).

Return Value

The table that was added to the shape collection.

Exceptions

exceptioncondition
ArgumentExceptionThrown when any required parameter is null or empty, or when the specified worksheet or cell range is invalid.
InvalidOperationExceptionThrown when the input data is in an unsupported format.

Examples

[C#]
IExcelDataWorkbook workbook = new ExcelDataWorkbook(testFile);
using (var pres = new Presentation())
{
    ExcelWorkbookImporter.AddTableFromWorkbook(pres.Slides[0].Shapes, 10, 10, workbook, worksheetName, "A1:D10");
    pres.Save("result.pptx", SaveFormat.Pptx);
}

See Also


AddTableFromWorkbook(IShapeCollection, float, float, string, string, string)

Retrieves a table from the specified Excel workbook file and adds it to the end of the given shape collection at the specified coordinates.

public static ITable AddTableFromWorkbook(IShapeCollection shapes, float x, float y, 
    string workbookPath, string worksheetName, string cellRange)
ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the table will be added.
xSingleThe X coordinate for positioning the table.
ySingleThe Y coordinate for positioning the table.
workbookPathStringThe path to the Excel workbook file.
worksheetNameStringThe name of the worksheet that contains the table.
cellRangeStringThe cell range that defines the table (for example, “A1:D10”).

Return Value

The table that was added to the shape collection.

Exceptions

exceptioncondition
ArgumentExceptionThrown when any required parameter is null or empty, or when the specified worksheet or cell range is invalid.
IOExceptionThrown when an I/O error occurs while accessing the workbook file.
InvalidOperationExceptionThrown when the input data is in an unsupported format.

Examples

[C#]
using (var pres = new Presentation())
{
    ExcelWorkbookImporter.AddTableFromWorkbook(pres.Slides[0].Shapes, 10, 10, workbookPath, worksheetName, "A1:D10");
    pres.Save("result.pptx", SaveFormat.Pptx);
}

See Also


AddTableFromWorkbook(IShapeCollection, float, float, Stream, string, string)

Retrieves a table from the specified Excel workbook file and adds it to the end of the given shape collection at the specified coordinates.

public static ITable AddTableFromWorkbook(IShapeCollection shapes, float x, float y, 
    Stream workbookStream, string worksheetName, string cellRange)
ParameterTypeDescription
shapesIShapeCollectionThe shape collection to which the table will be added.
xSingleThe X coordinate for positioning the table.
ySingleThe Y coordinate for positioning the table.
workbookStreamStreamA stream containing the workbook data.
worksheetNameStringThe name of the worksheet that contains the table.
cellRangeStringThe cell range that defines the table (for example, “A1:D10”).

Return Value

The table that was added to the shape collection.

Exceptions

exceptioncondition
ArgumentExceptionThrown when any required parameter is null or empty, or when the specified worksheet or cell range is invalid.
InvalidOperationExceptionThrown when the input data is in an unsupported format.

Examples

[C#]
using (var fStream = new FileStream(workbookPath, FileMode.Open, FileAccess.Read))
using (var pres = new Presentation())
{
    ExcelWorkbookImporter.AddTableFromWorkbook(pres.Slides[0].Shapes, 10, 10, fStream, worksheetName, "A1:D10");
    pres.Save("result.pptx", SaveFormat.Pptx);
}

See Also