Skip to main content
Row

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

ExternalWorkbook Interface

In This Article

An external workbook.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

#Declaration

public interface ExternalWorkbook :
    ISupportsContentChanged

#Remarks

A workbook can be a non-visual object, such as the Workbook, or the document loaded into the spreadsheet control (available via the SpreadsheetControl.Document property).

The following code snippet demonstrates how to create an external workbook, fill it with data and add to the ExternalWorkbookCollection.

Workbook externalWorkbook = new Workbook();
externalWorkbook.Worksheets[0].Import(CreateDataTable(10), false, 0, 0);
externalWorkbook.Options.Save.CurrentFileName = "ExternalDocument.xlsx";
foreach (IWorkbook item in spreadsheetControl1.Document.ExternalWorkbooks)
{
    if (item.Options.Save.CurrentFileName == externalWorkbook.Options.Save.CurrentFileName)
        return;
}
spreadsheetControl1.Document.ExternalWorkbooks.Add(externalWorkbook);

Subsequently the external workbook can be referenced in cell formulas. The following code inserts reference to the external workbook contained in the IWorkbook.ExternalWorkbooks collection.

if (spreadsheetControl1.Document.ExternalWorkbooks.Count == 0)
{
    MessageBox.Show("Add a workbook to the ExternalWorkbooks collection");
    return;
}
IWorkbook extWorkbook = (IWorkbook) spreadsheetControl1.Document.ExternalWorkbooks[0];
string extWorkbookName = extWorkbook.Options.Save.CurrentFileName;
string sFormula = String.Format("=[{0}]Sheet1!A1", extWorkbookName);
spreadsheetControl1.Document.Worksheets[0].Cells["A1"].Formula = sFormula;

For more information on workbooks in the SpreadsheetControl, see the Workbook document.

See Also