Export to Excel

  • Hi,

    I want to export some data to excel i have to flush the data from excel and enter it , the first column would be clumn names.

    Kindly specify how to flush before pusing the new data. data entering into the excel is perfect.

    Thanks

    Regards
    Durai Nagarajan

  • Hi Guys,

    Kindly help with this issue.

    Regards
    Durai Nagarajan

  • Hi Durani

    Am not exactly aware of how to do this, but this is a thought you may want to consider.

    Create a template file and copy that over every time the package runs and import the new data in and rename the file if needed...

    This way you will have a blank sheet every time...

    Let me know if you need help with this and I will try...

    Cheers

    Vani

  • I dont think you can delet data from the excel file from the SSIS Excel Destination.

    You could creat a script task that runs before the DFT which does the job: opens the excel file and runs a macro that deletes all data in the desired sheet.

    Your script could read as follows (be aware this is just written code, not tested)

    - I Assume you have a variable named "ExcelFileName" that contains the name of your file

    - I assume that you have Excel installed on the machine your SSIS package runs on

    Dim ExcelFileName As String = (Dts.Variables("ExcelFileName").Value)

    Dim ExcelApp As Object

    Dim wb As Object

    Try

    ExcelApp = CreateObject("Excel.Application")

    wb = ExcelApp.Workbooks.Open(ExcelFileName, 2, True)

    wb.Sheets("YourSheetName").Range("A1-IV65535").Clear

    Catch ex As Exception

    Dts.TaskResult = Dts.Results.Failure

    Finally

    If Not (wb Is Nothing) Then wb.Close(False)

    wb = Nothing

    ExcelApp.Quit()

    ExcelApp = Nothing

    End Try

    Unfortunately, without excel installed, this won't work...

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply