Creating Excel using C# in SSIS Script task.

Hi Guys,
I need to dynamically create an excel (with rows and columns) from a script task in a foreach container and just send an email to a group..
Can anyone guide me on this..
Thanks in advance...

Hi,
There are a number of things wrong with this request.
1. This is a scripting forum, not a C# development forum.
2. This is not an SSIS forum.
3. You show nothing about what you have already tried, what has worked, and what hasn't worked.
Your question is far too broad and vague, and you're not even asking in the right place.
You need to break down your requirements into small pieces and ask very specific questions in the correct forums. If you need for someone to design a solution for you, it's better to hire a paid consultant.
Bill

Similar Messages

  • Running a Select query against multiple sql servers using SSIS script task.

    Hi Guys,
    I need to fetch data from multiple sql servers using  SSIS scirpt task inside a foreach container.
    is there anyway i can build dynamic sql connections using ssis variables inside SSIS script task in each loop
    Please guide me or refer any blogs so that i will try..
    Thanks in advance.

    Your only options is using .net code, then it will be no different than using a console app in a loop.
    using (SqlConnection connection = new SqlConnection(connectionString))
    connection.Open();
    Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
    Console.WriteLine("State: {0}", connection.State);
    and so forth for each connection string
    the connection string would come from the ForEach loop
    Arthur My Blog

  • Consuming Web Services in SSIS Script Task

    Hello
    Sorry for my English, I' ll try to explain my problem.
    I am new to SSIS. Using this article http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/01/28/consuming-web-services-in-ssis-script-task.aspx I have tried to consume web service.
    1. I have created proxy class using VS Command Prompt
    2. A have added proxy class to Script Task
    3. But when I  want to create the instance of the proxy class, it can be accessed from the ScriptMain.cs. 
    I will be very pleased for the help!

    perhaps you missed this step:
    --> Modify the code and add Credentials before calling the web method:
    Public
    SubMain()
    Dim
    ws As NewService1
    ws.Credentials =
    New System.Net.NetworkCredential("user name",
    "password",
    "domain name")
    MsgBox("Square
    of 2 = "& ws.Square(2))
    Dts.TaskResult = Dts.Results.Success
    End
    Sub
    Arthur
    MyBlog
    Twitter

  • NameSpace for XML But in SSIS Script Task

    Hello, 
    I am creating an xml Document that pulls information from a staging table in sql. However the issue I am having is that i need  a namespace or a start element to handle a ':' but i keep getting its not a hexadecimal blah blah. 
    I feel like I have tried everything for this. 
    So maybe someone can help me  
           writer.WriteStartDocument()
     writer.WriteComment("edited with XMLSpy v2010 rel. 3 (http://www.altova.com) by MESMERiZE (MSM)")
    writer.WriteComment("Samply XML file generated by XMLSpy v2010 rel. 3 (http://www.altova.com)")
    So i have the comments show up fine but then i need it to show 
    <mssext:sendWarrantyContractBatch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mssext="http://jlrint.com/mss/message/sendwarrantycontract/1" xsi:schemaLocation="http://jlrint.com/mss/message/sendwarrantycontract/1
    FRS_000143-SendWarrantyContractMessages.xsd">
     I can get the websites and all the xmlns to show up fine that is not the issue the issue is the mssext:sendWarrantyContractBatch 
    IS there any way to get the Colon to show up ?? 
    Remember this is in a ssis script task with visual basic 2008 code 

    check this link. it has a method specified in the comments section
    http://blogs.lessthandot.com/index.php/datamgmt/dbprogramming/create-xml-files-out-of-sql-server-with/
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Convert ActiveX DTS script task to SSIS Script task - Please help

    Hello,
    I Have a ActiveX script that was used in a DTS package but I'm currently trying to convert all my DTS packages to SSIS.The script is tasked to run the package on a daily basis. Everything works fine except the ActiveX script. It gives an error on my DTSGlobalVariables.parent,
    I looked up this error and changed it to "DTS.Variables("User::VariableName").Value", in
    the SSIS script task (in VB) but now I'm getting error: 
    Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: The element cannot be found in a collection.
    ---> System.Runtime.InteropServices.COMException (0xC0010009): The element cannot be found in a collection.
    bij Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables100.get_Item(Object Index)
    bij Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
    --- Einde van intern uitzonderingsstackpad ---
    bij Microsoft.SqlServer.Dts.Runtime.Variables.get_Item(Object index)
    bij ST_f32fc12b60f34bebbbdfc0c5e5b40a96.vbproj.ScriptMain.Main()
    --- Einde van intern uitzonderingsstackpad ---
    bij System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    bij System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    bij System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
    bij System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
    I have tried to convert this ActiveX script into a SSIS script task in VB but I know hardly any VB... So I'm wondering what the best course of action for me is, should I try to convert it into the script task like I am trying now, if so, how do I make it
    work?
    Any help would be really really welcome.
    This is the original ActiveX script that needs to be converted:
    ' Visual Basic ActiveX Script
    Function Main()
    Dim sEnvironm
    Dim sServer
    Dim sSourceFile
    Dim sSourcePath
    Dim sBackupPath
    Dim sErrorPath
    Dim sFileName
    Dim sUDLPath
    ' Set vars
    ' First 2 are depending on the server and db
    ' FILL IN THE RIGHT VALUES
    sEnvironm = "MON_Datamart"
    sServer = "BrechtProesmans"
    ' --- DO NOT CHANGE ANYTHING BELOW THIS LINE ---
    sSourceFile = "C:\Program Files\Microsoft SQL Server\MON_Datamart\SourceFiles\tbl_L00T1.txt"
    sSourcePath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\SourceFiles\"
    sBackupPath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\BackupFiles\"
    sErrorPath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\ErrorFiles\"
    sFileName = "tbl_L00T1.txt"
    sUDLPath = "C:\Program Files\Microsoft SQL Server\MON_Datamart\MON_Datamart.udl"
    ' Initial
    FoundError = False
    ' Get a handle to the Package object.
    Set oPackage = DTSGlobalVariables.Parent
    ' Update DTSConnections
    Set oConnection = oPackage.Connections("tbl_L00T1.txt")
    oConnection.DataSource = sSourceFile
    Set oConnection = oPackage.Connections("Datamart")
    oConnection.UDLPath = sUDLPath
    Set oConnection = oPackage.Connections("Truncate")
    oConnection.UDLPath = sUDLPath
    ' Update DTSTasks
    Set oTask = oPackage.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask
    oTask.SourceObjectName = sSourceFile
    oTask.DestinationObjectName = sEnvironm & ".dbo.stg_tbl_L00T1"
    ' Set Global vars
    DTSGlobalVariables("SourcePath").Value = sSourceFile
    DTSGlobalVariables("BackupPath").Value = sBackupPath
    DTSGlobalVariables("ErrorPath").Value = sErrorPath
    DTSGlobalVariables("FileName").Value = sFileName
    ' Clean up.
    Set oTask = Nothing
    Set oConnection = Nothing
    Set oPackage = Nothing
    Main = DTSTaskExecResult_Success
    End Function

    Set a breakpoint and tell us on what line it dies, at the same time, you can inspect the variable values in the Auto window (if there are) as it merely perhaps is an issue with values not being passed in.
    Arthur
    MyBlog
    Twitter

  • SSIS script task using visual c# 2012 language when creating package in Visual Studio 2013

    Is it right or my installation was all wrong.
    When I am trying to use a script task in an SSIS package using Visual Studio 2013, the available languages are visual c# and VB 2012.
    I was expecting to find visual c# and VB 2013 since I was using Visual Studio 2013.
    I already installed the "Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013" available for sql 2014
    Please help clarify this. Thanks beforehand.
    Paulino

    Hi Paulino,
    According to your description, the ScriptLanguage property of C# script tasks show "Microsoft Visual C# 2012” in SSDT-BI for VS 2013.
    After testing the issue in my environment, I can reproduce it in SSDT-BI for VS 2013. And I find that the ScriptLanguage property of C# script tasks show "Microsoft Visual C# 2010” in SSDT, and show "Microsoft Visual C# 2012” in SSDT for SSDT –
    BI for VS2012. It only appear in SSDT-BI for VS 2013.
    The issue is by design. But we can check "Do not show this again." to ignore the dialog and the task can be executed without any problem.
    The following feedback is for your reference:
    https://connect.microsoft.com/SQLServer/feedback/details/1027035/ssdt-bi-for-vs-2013-compatibility-issue
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • SSIS - Script Task creates a DTS var and using Foreach loop, Execute SQL needs to INSERT into table from this DTS var.

    I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable.
    Each row in array represents a row is comma separated and is a row that must be inserted into a table. For example,
    X and Z are fields in the table
    X1, X2,....Xn
    Z1,Z2,...Zn
    I am using a Foreach Loop  to grab each row and then  Execute SQL Task to take each row from the array and insert each field per row in a table,
    The SQL is something like,
    INSERT dbo.table values(field1, field2,...fieldn) arrayFields?
    What should this this INSERT look like?

    I guess you implemented
    Shredding a Recordset
    Based on what I understood (correct me if I am wrong) you have difficulties mapping the input parameters, if so here is the guide
    http://www.sqlis.com/sqlis/post/The-Execute-SQL-Task.aspx
    In short it might look like
    INSERT dbo.table  (ColumnA, ColumnB,...) VALUES (?,?...)
    The syntax for the T-SQL INSERT is http://technet.microsoft.com/en-us/library/dd776381%28v=sql.105%29.aspx
    Arthur
    MyBlog
    Twitter

  • SSIS/Script Task/ VB 2008 Help Urgent...

    Hi Guys, 
    Simple Script Task, just rename Excel tab, here is my code...
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports Microsoft.Office.Interop.Excel
    Imports System.IO
    Imports System.Text
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
    Public Sub Main()
    Dts.VariableDispenser.LockForRead("User::FileName") ' File Name Variable
    Dim variablesList As Variables
    Dts.VariableDispenser.GetVariables(variablesList)
    'Dim SFileName As String
    'SFileName = variablesList("User::Filename").Value.ToString
    ' Dim vars As Variables 'New Added For Variable
    Dim oMissing As Object = System.Reflection.Missing.Value
    Dim xl As New Microsoft.Office.Interop.Excel.ApplicationClass()
    Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
    Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
    'Dts.VariableDispenser.LockForRead("Filename") 'New Added For Variable
    'Start For Variable
    'Dim File As String 'New Added For Variable
    'File = CType(vars("Filename").Value, String) 'New Added For Variable
    'MsgBox(Prompt:="Filename")
    'Dim laPath As String = "C:\Excel\ABC_dr_daily_lf_10-07-14.xls" 'My File Name
    Dim lapath As String = variablesList("User::FileName").Value.ToString 'New Added For Variable
    'MsgBox(Prompt:="Filename")
    xlBook = DirectCast(xl.Workbooks.Open(laPath, oMissing, oMissing, oMissing, oMissing, oMissing, _
    oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, _
    oMissing, oMissing, oMissing), Workbook)
    xlSheet = DirectCast(xlBook.Worksheets.Item(1), Worksheet)
    xlSheet.Name = "data"
    xlBook.Save()
    xl.Application.Workbooks.Close()
    Dts.TaskResult = ScriptResults.Success
    End Sub
    End Class
    Finally I intalled MS Excel 2007 on my Dev Server. Here is the error that I am receiving....
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: 
    Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application
    '. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}'
    failed due to the following error: Library not registered. 
    Please help me, this is very urgent.
    Thank You.

    No I didn't upgrade my SQL Server. OMG this error making me ehhhhhh. 
    Here I solve my problem. 
    RUN>REGEDIT>  and look for "Office.Interop.Excel" and delete the old version. I am using Excel 2007, 14.0. 
    It solve my Problem. 
    Thanks All.

  • SSIS : Read Rows from an Object variable in SSIS Script Task which is looped many times.

    Hello All,
    Here is what I am trying to do...
    1. I am having two rows, one column in an Object Variable. (vLoopCountObj).
    2. I am having 30 Rows, 2 Columns in my second Object  Variable (vTableRowsObj)
    3. I have a FOR EACH LOOP which will run for number of rows in vLoopCountObj i.e 2 times here.
    4. I have a Script Task inside the FOR EACH LOOP to display all the rows of vTableRowsObj.
    5. When I execute, 30 Rows gets displayed only once. It will not display when the loop goes for second iteration. Please help me to display for second time.
    6. I have used below code to display the rows whithin the script task which is in SSIS dataflow task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Collections
    Imports System.Data.OleDb
    Public Class ScriptMain
    Public Sub Main()
    Dim oleDA As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim col As DataColumn
    Dim row As DataRow
    Dim sMsg As String
    oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
    MsgBox("Number of Rows " + dt.Rows.Count.ToString())
    For Each row In dt.Rows
    For Each col In dt.Columns
    sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
    Next
    MsgBox(sMsg)
    sMsg = ""
    Next
    Dts.TaskResult = Dts.Results.Success
    End Sub
    End Class

    Hi Raj,
    It is verrrry interesting issue. I can also confirm that it doesnt loop again. I've made a simple test and figured that in the second loop even you fill the Dataadapter, record count is zero. Which brings me up to the idea: Somehow, after you read the object
    variable resultset, you can not read it again in the for each loop.
    Strange, probably a bug or a technical issue that is beyond my existing knowledge.
    I can provide a workaround. You can also loop in script task for first variable. (Nested loops)
    Let other members to examine and comment on this.
    Regards
    Onur
    (For others who also wants to test, here is my scenario
    Execute SQL Task 1:
    Query: SELECT 1 as Cnt UNION ALL SELECT 2 as Cnt
    Resultset: Full Resultset
    ResultSet Tab: Name: 0, Variable Name: User::vLoopCountObj;
    Execute SQL Task 2:
    Query: SELECT 1 as ColA, 2 as ColB UNION ALL SELECT 3 as ColA, 4 as ColB UNION ALL SELECT 5 as ColA, 6 as ColB
    Resultset: Full Resultset
    ResultSet Tab: Name: 0, Variable Name: User::vTableRowsObj;
    For Each Loop Container:
    Collection: Enum: ForEach ADO Enum
    Source Object: User::vLoopCountObj
    Enum Mode: Rows n the first Table
    Script Task:
    ReadOnlyVariables: User::vTableRowsObj
    Script Source:
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Collections
    Imports System.Data.OleDb
    Public Class ScriptMain
    Public Sub Main()
    Dim oleDA As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim col As DataColumn
    Dim row As DataRow
    Dim sMsg As String
    oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
    Dts.Events.FireInformation(-1, "START!!!!!!!!!!!!!!", "START LOOP", "", 0, True)
    Dts.Events.FireInformation(1, "RowCount: ", dt.Rows.Count.ToString(), "", 0, True)
    For Each row In dt.Rows
    For Each col In dt.Columns
    sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
    Next
    Dts.Events.FireInformation(1, "Msg: ", sMsg, "", 0, True)
    sMsg = ""
    Next
    Dts.TaskResult = ScriptResults.Success
    End Sub
    End Class
    BI and ERP Senior Consultant @ Nexum Bogazici
    If it is, Please dont forget to mark as answered or at least vote as helpful if the post helps you in any ways.

  • Getting COM Component error while opening SSIS Script task.

    Hi All,
    While click on EDIT SCRIPT Button in script task it's not opening the script editing window.
    Getting below error message:
    "Error HRESULT E_FAIL has been returned from a call to a COM component. (EnvDTE)"
    We have added ADODB reference in script task.
    Thanks in advance, please give some suggestion.

    I am using SSIS 2008 R2.
    When I reload the package, script task visual studio opens first time, next time when I try to open script task visual studio from EDIT SCRIPT Button it gives below error:
    "Error HRESULT E_FAIL has been returned from a call to a COM component. (EnvDTE)"

  • SSIS Script task not executing macro through SQL Agent (but it does through bids)

    <p>Hello everyone,</p><p>I am having an issue with SQL Agent when executing a macro contained in a script task component. The script task actually opens an excel file, runs the macro, save and closes the file. </p><p>When
    I execute the package via BIDS/Visual studio, it works like a charm. However, when i execute the package with SQL agent, the package runs successfully but it seems that the macro is not executed as the excel file has not been modified as it should have. Also,
    the history log does not show any error messages. </p><p>Could </p>

    Thanks!I did create a credential and a proxy too but still the macro is not executed.I have searched online for solutions but no one has experimented this kind of issue before it seems. Please have a look at the script task code:
    Imports
    Excel = Microsoft.Office.Interop.Excel
    Imports
    System
    Imports
    System.Data
    Imports
    System.Math
    Imports
    Microsoft.SqlServer.Dts.Runtime
    <System.AddIn.AddIn(
    "ScriptMain", Version:="1.0",
    Publisher:="", Description:="")>
    <System.CLSCompliantAttribute(
    False)> _
    Partial
    Public
    Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End
    Enum
    Public
    Sub Main()
    Dim Macro_name
    As
    String
    Dim ExcelObject
    As
    New Microsoft.Office.Interop.Excel.Application
    Dim oBook
    As Microsoft.Office.Interop.Excel.Workbook
    Dim oBooks
    As Microsoft.Office.Interop.Excel.Workbooks
    Try
    Macro_name =
    "Macro001"
    ExcelObject =
    CType(CreateObject("Excel.Application"),
    Excel.Application)
    ExcelObject.Visible =
    True
    ExcelObject.UserControl =
    False
    ExcelObject.DisplayAlerts =
    False
    oBooks = ExcelObject.Workbooks
    oBook =
    CType(oBooks.Open("C\Book1.xls"),
    Excel.WorkbookClass)
    ExcelObject.Run(Macro_name)
    Catch ex
    As Exception
    ExcelObject.Application.Quit()
    ExcelObject.DisplayAlerts =
    True
    ExcelObject =
    Nothing
    End
    Try
    Dts.TaskResult = ScriptResults.Success
    End
    Sub
    End
    Class

  • Using SSIS Script task to populate data from one table to another

    I have two tables Table A and Table B. Need to insert data into Table B from Table A. First, I truncate Table B and then insert. Few columns in Table A and Table are similar. However, I need to join with
    other tables Table C, Table D etc with Table B in order to populate the columns in Table B. Could someone please provide the code snippet to achieve this.

    Appreciate your quick response Prasad. Below is the code I'm using to achieve.
    Public Sub Main()
            Dim connEOCDB As SqlClient.SqlConnection = GetDBProdConnection(Me)
            Dim trans As SqlClient.SqlTransaction = connEOCDB.BeginTransaction()
            Try
                Dim TableA As New DataTable
                Dim TableB As New DataTable
                Dim DataadapterTableA As New SqlClient.SqlDataAdapter()
                DataadapterTableA.SelectCommand = New SqlClient.SqlCommand("select * from TableA", connEOCDB, trans)
                DataadapterTableA.Fill(TableA)
                Dim DataAdapterTableB As New SqlClient.SqlDataAdapter()
                DataAdapterTableB.DeleteCommand = New SqlClient.SqlCommand("Truncate table dbo.TableB", connEOCDB, trans)
                DataAdapterEmpExtdT.InsertCommand = New SqlClient.SqlCommand("insert into dbo.TableB (Col1,Col2,Col3,.....) values (@Col1,@Col2,@Col3...)", connEOCDB, trans)
    Could you please let me know how I can assign values to @Col1, @Col2 etc from
    DataadapterTableA.Fill(TableA). Also, as mentioned earlier, I need to use joins to populate @Col3 etc as well.
    Please advise.

  • File is corrupted error while creating excel using xml

      Hi have created one excel file using XML code and sent it to mail as attachement. But when i open it, it displays error  message - file is corrupted and cannot be opened.
    below is my code - please review and tell what is wrong in it ASAP :
    * Creating a ixml Factory
       l_ixml = cl_ixml=>create( ).
    * Creating the DOM Object Model
       l_document = l_ixml->create_document( ).
    * Create Root Node 'Workbook'
       l_element_root  = l_document->create_simple_element( name = 'Workbook'  parent = l_document ).
       l_element_root->set_attribute( name = 'xmlns'  value = 'urn:schemas-microsoft-com:office:spreadsheet' ).
       ns_attribute = l_document->create_namespace_decl( name = 'ss'  prefix = 'xmlns'  uri = 'urn:schemas-microsoft-com:office:spreadsheet' ).
       l_element_root->set_attribute_node( ns_attribute ).
       ns_attribute = l_document->create_namespace_decl( name = 'x'  prefix = 'xmlns'  uri = 'urn:schemas-microsoft-com:office:excel' ).
       l_element_root->set_attribute_node( ns_attribute ).
    * Create node for document properties.
       r_element_properties = l_document->create_simple_element( name = 'TEST_REPORT'  parent = l_element_root ).
       l_value = sy-uname.
       l_document->create_simple_element( name = 'Author'  value = l_value  parent = r_element_properties  ).
    * Styles
       r_styles = l_document->create_simple_element( name = 'Styles'  parent = l_element_root  ).
    * Style for Header
       r_style  = l_document->create_simple_element( name = 'Style'   parent = r_styles  ).
       r_style->set_attribute_ns( name = 'ID'  prefix = 'ss'  value = 'Header' ).
       r_format  = l_document->create_simple_element( name = 'Font'  parent = r_style  ).
       r_format->set_attribute_ns( name = 'Bold'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Interior' parent = r_style  ).
       r_format->set_attribute_ns( name = 'Color'   prefix = 'ss'  value = '#92D050' ).
       r_format->set_attribute_ns( name = 'Pattern' prefix = 'ss'  value = 'Solid' ).
       r_format  = l_document->create_simple_element( name = 'Alignment'  parent = r_style  ).
       r_format->set_attribute_ns( name = 'Vertical'  prefix = 'ss'  value = 'Center' ).
       r_format->set_attribute_ns( name = 'WrapText'  prefix = 'ss'  value = '1' ).
       r_border  = l_document->create_simple_element( name = 'Borders'  parent = r_style ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Bottom' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Left' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Top' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Right' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
    * Style for Data
       r_style1  = l_document->create_simple_element( name = 'Style'   parent = r_styles  ).
       r_style1->set_attribute_ns( name = 'ID'  prefix = 'ss'  value = 'Data' ).
       r_border  = l_document->create_simple_element( name = 'Borders'  parent = r_style1 ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Bottom' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Left' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Top' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Right' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
    * Worksheet
       r_worksheet = l_document->create_simple_element( name = 'Worksheet'  parent = l_element_root ).
       r_worksheet->set_attribute_ns( name = 'Name'  prefix = 'ss'  value = 'Sheet1' ).
    *  r_worksheet->set_attribute_ns( name = 'Protected'  prefix = 'ss'  value = '1' ).    " WORKING
    * Table
       r_table = l_document->create_simple_element( name = 'Table'  parent = r_worksheet ).
       r_table->set_attribute_ns( name = 'FullColumns'  prefix = 'x'  value = '1' ).
       r_table->set_attribute_ns( name = 'FullRows'     prefix = 'x'  value = '1' ).
    * Column Formatting
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '40' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '90' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '140' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '150' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '90' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '90' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '90' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '90' ).
       r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).
       r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '90' ).
    * Blank Row
       r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).
    * Column Headers Row
       r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).
       r_row->set_attribute_ns( name = 'AutoFitHeight'  prefix = 'ss'  value = '1' ).
    * RFQ No.
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'RFQ No.'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    * RFQ Line Item No
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'RFQ Line Item No.'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    * Material
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'Material'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    * Quantity
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'Quantity'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    *  Order UNIT
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'Order Unit'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    *  Delivery Date
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'Delivery Date'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    *  RFQ Creation Date
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'RFQ Creation Date'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    *  RFQ Deadline Date
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'RFQ Deadline Date'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    * Price
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
       r_data = l_document->create_simple_element( name = 'Data'  value = 'Net Price'  parent = r_cell ).
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    ** Login
    *  r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
    *  r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
    *  CONCATENATE 'Login - ' lv_date+6(2) '/' lv_date+4(2) '/' lv_date+0(4) INTO l_value.
    *  r_data = l_document->create_simple_element( name = 'Data'  value = l_value  parent = r_cell ).
    *  r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    * Blank Row after Column Headers
       r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
    * Data Table
       LOOP AT it_final1 INTO wa_final1.
         CLEAR l_value.
         r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).
    * RFQ No.
         r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
         r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
         CLEAR l_value.
         l_value = wa_final1-ebeln .
    *    CONDENSE l_value NO-GAPS.
         r_data = l_document->create_simple_element( name = 'Data'  value = l_value  parent = r_cell ).           " Data
         r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'String' ).                               " Cell format
    * Line Item No
         CLEAR l_value.
         r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
         r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
         l_value = wa_final1-ebelp.
         r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data
         r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'Number' ).                               " Cell format
    * Material
         CLEAR l_value.
         r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
         r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
         l_value = wa_final1-txz01.
         r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data
         r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'String' ).                               " Cell format
    * RFQ QTY
         CLEAR l_value.
         r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
         r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
         l_value = wa_final1-ktmng.
         r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data
         r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'Number' ).                               " Cell format
    * UNIT
         CLEAR l_value.
         r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
         r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
         l_value = wa_final1-meins.
         r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell

    How to make a particular column non editable?
    Make your style protected and pass that style name to your required column while passing data.
    for example:
    Find below the code for protection of a style.
    Last two lines are very important.
    * Style for Headert
       r_style  = l_document->create_simple_element( name = 'Style'   parent = r_styles  ).
       r_style->set_attribute_ns( name = 'ID'  prefix = 'ss'  value = 'Headert' ).
       r_format  = l_document->create_simple_element( name = 'Font'  parent = r_style  ).
       r_format->set_attribute_ns( name = 'Bold'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Interior' parent = r_style  ).
       r_format->set_attribute_ns( name = 'Color'   prefix = 'ss'  value = '#B2FF64' ).      
       r_format->set_attribute_ns( name = 'Pattern' prefix = 'ss'  value = 'Solid' ).
       r_format  = l_document->create_simple_element( name = 'Alignment'  parent = r_style  ).
       r_format->set_attribute_ns( name = 'Vertical'  prefix = 'ss'  value = 'Bottom' ).
       r_format->set_attribute_ns( name = 'WrapText'  prefix = 'ss'  value = '1' ).
       r_border  = l_document->create_simple_element( name = 'Borders'  parent = r_style ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Bottom' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Left' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Top' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Border'   parent = r_border  ).
       r_format->set_attribute_ns( name = 'Position'  prefix = 'ss'  value = 'Right' ).
       r_format->set_attribute_ns( name = 'LineStyle'  prefix = 'ss'  value = 'Continuous' ).
       r_format->set_attribute_ns( name = 'Weight'  prefix = 'ss'  value = '1' ).
       r_format  = l_document->create_simple_element( name = 'Protection'  parent = r_style  ).
       r_format->set_attribute_ns( name = 'Protected'  prefix = 'ss'  value = '1' ).

  • SSIS script task failing when deployed as project in SSIS 2012

    Yes , it's the classic "my package works inside SSDT but dies when I deploy it". I  have a fairly good idea what the problem is. I have a line of code that looks in a directory. My guess is that the account that is used to run packages out
    of SSISDB doesn't have access to the directory in question. My question is, what exactly needs to be set properly in order for packages to run properly in the package deployment model.
    Error message: Exception has been thrown by the target of an invocation.
    Code:
    using System;
    using System.Data;
    using System.IO;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
     public void Main()
                String FilePath;
                FilePath = Dts.Variables["InitialDirectoryFullPath"].Value.ToString();
                if (Directory.GetFiles(FilePath).Length == 0)
                    Dts.Variables["FilesExist"].Value = false;
                else
                    Dts.Variables["FilesExist"].Value = true;
                Dts.TaskResult = (int)ScriptResults.Success;
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

    You need to give the account which is executing package the access to the directory. If its from SQL Agent job, it might be using SQL Agent service account by default. Then you've to give it required permissions
    Alternatively you can create a proxy account with required permissions and configure the job to use it
    http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
    Also you've not posted error message. Whatever I've suggested is by assuming that its a permission issue. If you can post error message we might be able to confirm on the actual cause of error.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Creating Excel Using OLE through ABAP

    Hi Experts,
    Can anyone help me in running an abap program to give an Excel file using OLE..
    Regards,
    Seshadri

    Hi Seshadri,
          Here is ur expected coding...
    REPORT ZCREATEEXCEL.
    TYPE-POOLS OLE2.
    DATA: EXCEL     TYPE OLE2_OBJECT,
          WORKBOOKS TYPE OLE2_OBJECT,
          WORKBOOK  TYPE OLE2_OBJECT.
    DATA: FILENAME LIKE RLGRAP-FILENAME.
    START THE EXCEL APPLICATION
      CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
      PERFORM ERR_HDL.
    PUT EXCEL IN FRONT
      SET PROPERTY OF EXCEL  'VISIBLE' = 1.
      PERFORM ERR_HDL.
    INFORM USER OF THE CURRENT STATUS
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
           EXPORTING
                PERCENTAGE = 0
                TEXT       = TEXT-I08
           EXCEPTIONS
                OTHERS     = 1.
    CREATE AN EXCEL WORKBOOK OBJECT
      CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOKS.
      PERFORM ERR_HDL.
      CALL METHOD OF WORKBOOKS 'ADD' = WORKBOOK.
      PERFORM ERR_HDL.
    EXCEL FILENAME
      CONCATENATE SY-REPID '_' SY-DATUM6(2) '_' SY-DATUM4(2) '_'
                  SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.
      CALL METHOD OF WORKBOOK 'SAVEAS' EXPORTING #1 = FILENAME.
      FORM ERR_HDL.
      IF SY-SUBRC <> 0.
        WRITE: / 'OLE ERROR: RETURN CODE ='(I10), SY-SUBRC.
        STOP.
      ENDIF.
    ENDFORM.
    hope it helps..

Maybe you are looking for