Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to load a workbook and update external references.

$
0
0
When the SpreadsheetControl loads a workbook containing external references, they are added to the IWorkbook.ExternalWorkbooks collection. However, the external references, created in this manner, are not "live". The references contain cached data and the SpreadsheetControl cannot update them.
To make a reference updateable, it should be replaced with a reference to a workbook instance.

This example demonstrates how to accomplish this. To create a workbook instance, a workbook file should be loaded to an instance of the Workbook class or to another SpreadsheetControl instance. Subsequently the ExternalWorkbookCollection.Replace method is used to replace the cached reference with a live external reference.
Note that a workbook name in the external reference should be identical to the WorkbookSaveOptions.CurrentFileName property of the referenced workbook instance when the workbook is added to the ExternalWorkbookCollection. That is, if the workbook instance is created by loading a file using a full path, the reference should contain the full path, e.g. 'C:\Temp\[Book1.xlsx]Sheet1'!B3. The string with the reference created in this manner might be too long and inconvenient in use. The Workbook.Options.Save.CurrentFileName property of a referenced workbook enables you to specify a name that is easier to read, for example, "MyExternalWorkBook". Replace the corresponding item of the ExternalWorkbookCollection with an instance of the workbook with a custom CurrentFileName, and use it in external references instead of the file name, e.g.  [MyExternalWorkBook]Sheet1!B3.

Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>