简体   繁体   中英

SSIS C# OpenXML to generate Excel File Failing

I am using OpenXML to generate Excel file using C# in an SSIS package.

I did this because we do not have Excel installed on the Server so this should work without needing Excel installed.

This works locally, but is failing when moving to the PROD server. It is failing on the script task and I am getting this error:

Executed as user: MI\SQLAgentAccount. Microsoft (R) SQL Server Execute     Package Utility  Version 11.0.5058.0 for 64-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  10:46:49 AM  Error: 2015-10-15 10:46:50.49     Code: 0x00000001     Source: Save To Excel Without Excel      Description: Exception has been thrown by the target of an invocation.  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  10:46:49 AM  Finished: 10:46:50 AM  Elapsed:  0.827 seconds.  The package execution failed.  The step failed.

I am including in the references the OpenXML and WindowBase objects and adding them with the "using" statements.

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;

Do these need to be registered with the GAC? Or is there a way to include them in the project (inside the script task within SSIS)? There is the setting for "Copy To Local" inside the C# script task in SSIS, but not sure what/how this would work inside SSIS.

Any help would be appreciated.

Yes, you need to ensure you have it available from the GAC and also copy the assembly to C:\\WINDOWS\\Microsoft.NET\\Framework\\

Just doing some research on this myself and found the following link that confirmed the issue and resolution: http://beyondrelational.com/modules/2/blogs/81/posts/11263/referencing-an-assembly-inside-ssis-script-task.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM