﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Integration Services  / SSIS Package to create Excel Spreadsheet fails in SQL Agent / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 12:16:24 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>Hi Charles,Did you managed to get it working. I have the similar issue.ThanksSree</description><pubDate>Mon, 12 Mar 2012 12:15:19 GMT</pubDate><dc:creator>skumbale</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>I was having this problem too.I fixed it by remote desktop'ing into the server that the SQL Server Agent was running on.  Instead of logging in with my own user account, I logged in with the same account the agent service is running under.  Then, I opened up Excel.It ran through all the first time user popups, like prompting me to verify my name and initials, if i wanted to activate excel, if i wanted to get automatic updates, etc.  Once I did that, the job started working.</description><pubDate>Thu, 18 Nov 2010 17:05:27 GMT</pubDate><dc:creator>SlowJamuels</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>Hiya, I had this problem too.The way I solved it, was by creating a folder called "Desktop" in "C:\Windows\System32\config\systemprofile\" and I was able to run it without any problems.I hope that helps :)</description><pubDate>Tue, 11 May 2010 08:34:24 GMT</pubDate><dc:creator>ajagadambe</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>if you use microsoft.interop.excel then only admin and the system user had the permission to generate the excel.so create a proxy account and call the job through that account.</description><pubDate>Mon, 26 Apr 2010 06:04:32 GMT</pubDate><dc:creator>Muthamil_c</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>What account does the SQL Agent run under and does that account have the appropriate share permissions to write files?</description><pubDate>Mon, 12 Apr 2010 15:51:14 GMT</pubDate><dc:creator>CinnamonGirl</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>I physically signed on to the server as Admin and executed the package in BDIS and it worked fine and wrote the spreadsheet to the file as it is suppose to do..  I then opened the SQL Server Management Studio and connected to Integration Services and executed the package from there, and again it worked fine .  I then created a new SQL Agent job being signed on as Admin and when I ran the job which executed the package, it failed with the same error  message as before.</description><pubDate>Fri, 19 Mar 2010 12:38:59 GMT</pubDate><dc:creator>charles tisch</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>If you physically log in to the server as user XECC\Administrator and then execute the package through BIDS, does it execute OK?</description><pubDate>Fri, 19 Mar 2010 11:52:30 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>Everything on the server is 32 bit.  There is no 64 bit software.</description><pubDate>Fri, 19 Mar 2010 11:38:28 GMT</pubDate><dc:creator>charles tisch</dc:creator></item><item><title>RE: SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>How you are calling the SSIS package from the job, I mean through dtexec? There are issues with support to 32 bot and 64 bit excel... Please read more on this....VG</description><pubDate>Fri, 19 Mar 2010 09:38:43 GMT</pubDate><dc:creator>VG-619426</dc:creator></item><item><title>SSIS Package to create Excel Spreadsheet fails in SQL Agent</title><link>http://www.sqlservercentral.com/Forums/Topic886366-148-1.aspx</link><description>I wrote a SSIS script task where I use VB code to read data from a database using ODBC and  then dynamically create an excel spreadsheet using the Microsoft.Office.Interop.Excel object.  The code then saves the spreadsheet to a directory folder on the sql server.    The server OS is 32 bit Windows Server 2008 Standard, and SQL Database is SQL 2005. When I execute the package in the SQL Server Business Development Studio on the server, it works perfectly and the package writes the spreadsheet to the folder on the server without any problem.  I then save the package on the server using "Server Storage" and I set up a scheduled job to run the package.  Every time the SQL Agent runs this job ,  I get this errorMessageExecuted as user: XECC\Administrator. Microsoft (R) SQL Server Execute Package Utility  Version 9.00.4035.00 for 32-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Started:  8:49:42 AM  Error: 2010-03-19 08:49:46.69     Code: 0x00000002     Source: create_spreadsheet      Description: The script threw an exception: Exception from HRESULT: 0x800A03EC  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  8:49:42 AM  Finished: 8:49:46 AM  Elapsed:  3.884 seconds.  The package execution failed.  The step failed.I have created many other packages before using  script tasks and I have used the sql agent to execute them,  and I never have had a problem before.  I should note that none of my previous packages used the Microsoft.Office.Interop.Excel object to create an Excel spreadsheet, so maybe this is some how causing the problem.I created the job step for executing the SSIS package  using SQL Server Authentication since I saved the package to the server using "Server Storage" with the same login account.I did a test and I commented out the statement in the VB script that actually saves the workbook to the folder on the server and when I executed the job in the SQL Agent with this statement commented out, the job worked fine without an error.  When I remove the comment and try to write the spreadsheet to the folder, I get the that same error .Here is my Vb code        sql = "select * from logs order by [0]"        cmd = New OdbcCommand(sql, cn)        rs = cmd.ExecuteReader        Dim app As New Microsoft.Office.Interop.Excel.Application        Dim WB As Microsoft.Office.Interop.Excel.Workbook        app.Visible = False        app.UserControl = False        app.DisplayAlerts = False        WB = app.Workbooks.Add        WB.Application.Cells.Select()        WB.Application.Selection.NumberFormat = "0"        Do While rs.Read = True            k = CType(rs("0"), Integer)                       For i = 0 To 170                If IsDBNull(rs.Item(i)) = True Then GoTo finish                j = i + 1                WB.Application.Cells._Default(k, j) = rs.Item(i)            Nextfinish:        Loop        rs.Close()        WB.Application.Cells.EntireColumn.AutoFit()        WB.Application.Range("A1").Select()        WB.Sheets(1).Name = "logs"        When I comment this statement out, the SQL Agent job works fine.=================================================='WB.SaveAs("D:/excel_folder/logs.xls")================================================        WB.Close()        WB = Nothing        app.Quit()        app = Nothing        System.GC.Collect(0)        System.GC.WaitForPendingFinalizers()        cn.Close()        cn.Dispose()        Dts.TaskResult = Dts.Results.SuccessI am wondering if because Excel is involved now is there something in security that is causing the job to fail?I am wondering if because Excel is involved now in this package is there something in security that is causing the job to fail?</description><pubDate>Fri, 19 Mar 2010 07:44:30 GMT</pubDate><dc:creator>charles tisch</dc:creator></item></channel></rss>