ServerDocument::Save Method ()
Saves any changes that were made to the document by using the ServerDocument class.
Assembly: Microsoft.VisualStudio.Tools.Applications.ServerDocument (in Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)
| Exception | Condition |
|---|---|
| DocumentClosedException | The ServerDocument has been closed. |
| MissingHostItemIdException | The Id property of a CachedDataHostItem is null or empty. |
| MissingDataIdException | The Id property of a CachedDataItem is null or empty. |
| MissingTypeException | The DataType property of a CachedDataItem is null or empty. |
The Save method saves any changes you have made to the cached data or to the deployment manifest URL in the document. If you created the ServerDocument object by using a document on disk, this method saves these changes to disk. If you created the ServerDocument object by using a document in memory, this method saves these changes to the memory buffer.
The following code example creates a new ServerDocument for a specified Excel workbook, modifies the value of a string that is cached in a worksheet by using the SerializeDataInstance method, and then saves the change by using the Save method.
This example requires:
A document-level customization for Excel that has a Sheet1 class in the ExcelWorkbook1 namespace, and a cached string in the Sheet1 class named CachedString.
A console application project or some other non-Office project.
References to the following assemblies:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll and Microsoft.VisualStudio.Tools.Applications.Runtime.dll (if the project targets the .NET Framework 4 or the .NET Framework 4.5).
or
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll and Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (if the project targets the .NET Framework 3.5).
Imports (for Visual Basic) or using (for C#) statements for Microsoft.VisualStudio.Tools.Applications and Microsoft.VisualStudio.Tools.Applications.Runtime namespaces at the top of your code file.