OfficeSession Class |
Namespace: Atalasoft.Imaging.Codec.Office
The OfficeSession type exposes the following members.
Name | Description | |
---|---|---|
OfficeSession | Initializes a new instance of the OfficeSession class |
Name | Description | |
---|---|---|
Close |
Closes the OfficeSession, releasing any open Office applications.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize |
Releases unmanaged resources and performs other cleanup operations before the
OfficeSession is reclaimed by garbage collection.
(Overrides ObjectFinalize.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Open | ||
ToString | Returns a string that represents the current object. (Inherited from Object.) |
// By default, the office decoder will create a new session for each document decoded. // This leads to performance degradation if the same decoder is used to decode several files. // To remedy this, the OfficeSession class was created, which encapulates a set of running Office // applications, leaving them open for as long as they are needed. // The session implements IDisposable, and must be disposed or have the Close method called when it is no longer needed. using(OfficeSession officeSession = OfficeSession.Open()) { OfficeDecoder officeDecoder = new OfficeDecoder(officeSession); // With the OfficeDecoder created using the session, we now decode images as usual. // The decoder will now use the Office applications provided by the OfficeSession. using(Stream wordDocumentStream = File.OpenRead("wordDocument.doc")) { AtalaImage wordDocumentImage = officeDecoder.Read(wordDocumentStream, null); } using(Stream wordXmlDocumentStream = File.OpenRead("wordXmlDocument.docx")) { AtalaImage wordXmlDocumentImage = officeDecoder.Read(wordXmlDocumentStream, null); } using(Stream excelDocumentStream = File.OpenRead("excelDocument.ppt")) { AtalaImage excelDocumentImage = officeDecoder.Read(excelDocumentStream, null); } using(Stream excelXmlDocumentStream = File.OpenRead("excelXmlDocument.pptx")) { AtalaImage excelXmlDocumentImage = officeDecoder.Read(excelXmlDocumentStream, null); } }