[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IWorkbook.UpdateExcelLink

UpdateExcelLink Method

Updates the Excel link with the specified name.

Use this method to refresh a linked workbook reference identified by name. To obtain available link names, use GetExcelLinkSources().

Declaration
void UpdateExcelLink(string name)
Sub UpdateExcelLink(name As String)
Parameters
Type Name Description
string name

The name of the Excel link to update. This value should match one of the linked workbook names; null behavior is undefined.

string sourceFileName = "SourceWorkbook.xlsx";
IWorkbook sourceWorkbook = new Workbook();
sourceWorkbook.Worksheets[0].Range["A1"].Value = "Updated value";
sourceWorkbook.Save(sourceFileName);
worksheet.Range["B1"].Formula = $"='[{sourceFileName}]Sheet1'!A1";
foreach (string linkSource in workbook.GetExcelLinkSources())
{
    workbook.UpdateExcelLink(linkSource);
}
object updatedValue = worksheet.Range["B1"].Value;

Updates the specified Excel link by using the content from another workbook.

The name value should match the linked workbook name used in the external reference.

Declaration
void UpdateExcelLink(string name, IWorkbook sourceWorkbook)
Sub UpdateExcelLink(name As String, sourceWorkbook As IWorkbook)
Parameters
Type Name Description
string name

The name of the linked workbook to update.

IWorkbook sourceWorkbook

The workbook instance for the link.

worksheet.Range["B1"].Formula = "='[SourceWorkbook.xlsx]Sheet1'!A1";
IWorkbook sourceWorkbook = new Workbook();
sourceWorkbook.Worksheets[0].Range["A1"].Value = "Hello";
workbook.UpdateExcelLink("SourceWorkbook.xlsx", sourceWorkbook);
object updatedValue = worksheet.Range["B1"].Value;