|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How to: Programmatically Cache a Data Source in an Office Document
The features in this topic are available only if you have the required applications installed.
For more information, see.
You can programmatically add a data object to the data cache in a document by calling the
StartCaching method of a host item, such as a , , or . The
StartCaching method is private, but it appears in IntelliSense.
When you use the
StartCaching method to add a data object to the data cache, the data object does not need to be declared with the attribute. However, the data object must meet certain requirements to be added to the data cache. For more information, see .
To programmatically cache a data object
Declare the data object at the class level, not inside a method. This example assumes that you are declaring anamed
dataSet1that you want to cache programmatically.
Instantiate the data object, and then call the
StartCachingmethod of the document or worksheet instance and pass in the name of the data object.