ImageGear .NET v25.2 - Updated
Getting Started with ImageGear Office
Developer Guide > How to Work with... > Office > Getting Started with ImageGear Office
Before using the ASP.NET samples, a path to the Office components must be added to the registry. See Samples for details.

Office Samples and Tutorials

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:

ImageGear.Formats.Office Namespace

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;

Converting Office Files to PDF

It is easy to convert all types of Office documents that we support to PDF. See code examples in Microsoft Office Documents to PDF.

Office Dependencies

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.

Working with Office Files

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 ImGearDocumentImGearExcelBookDocumentImGearExcelSheetDocumentImGearPowerPointDocument, or ImGearWordDocument objects, it is necessary to dispose of them after they are no longer being used.

ImageGear .NET does not currently support password-protected Office documents (.doc, .docx,  .xls, .xlsx, .ppt, and pptx). If you attempt to load a password-protected Office document, System.NotSupportedException is thrown.

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

The LibreOffice Instance Manager

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.

Is this page helpful?
Yes No
Thanks for your feedback.