User Guide > How to Work with... > Formats with Additional Functionality > Office > Getting Started with ImageGear Office |
Our suite of Office samples will help you get started using ImageGear’s Office capabilities.
This section also provides a step-by-step Office tutorial, which shows you how to create a new ImageGear project using the Office component:
The ImageGear.Formats.Office namespace provides support for PowerPoint, Excel, and Word formats. This allows you to load and display Microsoft Word, Excel, and PowerPoint documents. It also allows you to extract text from Word and PowerPoint documents.
To enable the ImageGear.Formats.Office Namespace in your project, specify the following directive:
C# Example |
Copy Code |
---|---|
using ImageGear.Formats.Office; |
It is easy to convert all types of Office documents that we support to PDF. See code examples in Microsoft Office Documents to PDF.
NuGet packages make it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. See NuGet Packages for more information.
When loading extremely complex or large documents, the user interface can occasionally freeze. In order to avoid this, since all calls are thread safe, you can simply load the document in another thread.
When working with ImGearDocument, ImGearExcelBookDocument, ImGearExcelSheetDocument, ImGearPowerPointDocument, or ImGearWordDocument objects, it is necessary to dispose of them after they are no longer being used.
The best way is simply to use a using statement, like this:
C# Example |
Copy Code |
---|---|
using (FileStream inStream = new FileStream(fileIn, FileMode.Open, FileAccess.Read)) using (ImGearWordDocument wordDoc = (ImGearWordDocument)ImGearFileFormats.LoadDocument(inStream)) { // Your code here. } |
VB.NET Example |
Copy Code |
---|---|
Using inStream As New FileStream(fileIn, FileMode.Open, FileAccess.Read)
Using wordDoc As ImGearWordDocument = DirectCast(ImGearFileFormats.LoadDocument(inStream), ImGearWordDocument)
' Your code here.
End Using
End Using |
Otherwise, you can simply call the object’s Dispose method.
C# Example |
Copy Code |
---|---|
using (FileStream inStream = new FileStream(fileIn, FileMode.Open, FileAccess.Read)) { // Load Office document. ImGearWordDocument wordDoc = (ImGearWordDocument)ImGearFileFormats.LoadDocument(inStream); // Your code here. // Dispose of the document when we are done with it. wordDoc.Dispose(); } |
VB.NET Example |
Copy Code |
---|---|
Using inStream As New FileStream(fileIn, FileMode.Open, FileAccess.Read)
Dim wordDoc As ImGearWordDocument = DirectCast(ImGearFileFormats.LoadDocument(inStream), ImGearWordDocument)
' Your code here.
wordDoc.Dispose()
End Using |
If you want to adjust the number of LibreOffice processes ImageGear uses to work with Office documents, you can tweak the settings exposed by the LibreOffice Instance Manager. See LibreOffice Instance Manager (LIM) for more information.