Making OfficeWriter available to your applications
There are several steps to make OfficeWriter available to your .NET applications:
- Install OfficeWriter
- Include System.Web
- Add references to OfficeWriter
- Include OfficeWriter in your code
Add a reference to System.Web
All of the OfficeWriter API objects (ExcelTemplate, ExcelApplication, PowerPointTemplate, PowerPointApplication, WordTemplate, WordApplication) have the output options for saving to disk, saving to memory stream, streaming to user in a page response. The last output option, streaming to the user, has a dependency on System.Web
. If you are developing a web application, the reference to System.Web
should have been added automatically. For other types of applications, you may need to add this reference.
If you are using Visual Studio .NET:
- Right-click the project name in the Solution Explorer and choose Add Reference.
- Click System and locate System.Web
Add a reference to OfficeWriter
There are two ways to do this:
- Make OfficeWriter available to a single application
- Make OfficeWriter available for all applications on machine
Method #1: Adding OfficeWriter to a specific application
- At the top level of your application, create a directory call bin.
- Copy SoftArtisans.OfficeWriter.ExcelWriter.dll, SoftArtisans.OfficeWriter.PowerPointWriter.dll, or SoftArtisans.OfficeWriter.WordWriter.dll from the install directory to your application's bin directory.
If you are using Visual Studio .NET:
- Right-click the project name in the Solution Explorer and choose Add Reference.
- Click Browse and navigate to C:\Program Files\SoftArtisans\OfficeWriter\bin.
- Choose Softartisans.OfficeWriter.ExcelWriter.dll, SoftArtisans.OfficeWriter.PowerPointWriter.dll, or SoftArtisans.OfficeWriter.WordWriter.dll and click Open.
- Click OK.
Method #2: Making OfficeWriter available to all applications on a machine
Step 1: Install OfficeWriter in the Global Assembly Cache (GAC)
These instructions can be used for installing SoftArtisans.OfficeWriter.ExcelWriter.dll, SoftArtisans.OfficeWriter.PowerPointWriter.dll or SoftArtisans.OfficeWriter.WordWriter.dll in the GAC; remember to change 'ExcelWriter' to 'WordWriter' or 'PowerPointWriter depending on the dll you wish to install:
- Open a command prompt window and move to the directory OfficeWriter\bin\dotnet20\.
- Enter gacutil /i SoftArtisans.OfficeWriter.ExcelWriter.dll.
- Open the file machine.config (in [Windows directory]\Microsoft.NET\Framework[.NET version directory]\CONFIG).
Step 2: Reference the copy of OfficeWriter in the GAC in machine.config or web.config
Add the following line to the assemblies node of machine.config:
OR
Create a text file containing the following lines, and save it as web.config. Save web.config at the top level of your application.
Include OfficeWriter in your code
On any page that uses OfficeWriter, make sure to add the appropriate using
statements:
As mentioned above, you will also need to make sure that System.Web
is included in your project.