insert row to Excel using C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Wallace

    insert row to Excel using C#

    I need to insert a row into an Excel spreadsheet using C#. I get a
    reference to the app, the workbook, the sheet. When I attempt to call
    Insert, I keep getting errors, probably because I'm not certain what the
    args are (and cannot find any documentation to help). I supplied the 2 args
    as I thought were correct ( Microsoft.Offic e.Inerop.Excel. XlDirection.xlU p,
    row_num ), but these don't seem correct. Can anyone please help or point me
    to a valid Web source?

    TIA,

    Tim


  • django

    #2
    Re: insert row to Excel using C#

    Your argument Microsoft.Offic e.Inerop.Excel. XlDirection.xlU p,
    row_num

    Inerop -->Interop

    Comment

    • Danny Tuppeny

      #3
      Re: insert row to Excel using C#

      "Tim Wallace" <twallace-ThisDoesNotBelo ng-AT-emailDOTcom> wrote in message
      news:OaDXoQ2yFH A.612@TK2MSFTNG P10.phx.gbl...[color=blue]
      >I need to insert a row into an Excel spreadsheet using C#. I get a
      >reference to the app, the workbook, the sheet. When I attempt to call
      >Insert, I keep getting errors, probably because I'm not certain what the
      >args are (and cannot find any documentation to help). I supplied the 2
      >args as I thought were correct (
      >Microsoft.Offi ce.Inerop.Excel .XlDirection.xl Up, row_num ), but these don't
      >seem correct. Can anyone please help or point me to a valid Web source?[/color]

      Can't you use ADO.NET with an Excel connection string instead? Then you just
      use T-SQL INSERT statements :)




      Comment

      • Tim Wallace

        #4
        Re: insert row to Excel using C#

        Thanks. I'll give it a try.

        By the way, in my code it reads "Interop"; I just mistyped it in my post.

        Tim

        "django" <lagwal@gmail.c om> wrote in message
        news:1128708181 .992873.214290@ g47g2000cwa.goo glegroups.com.. .[color=blue]
        > Your argument Microsoft.Offic e.Inerop.Excel. XlDirection.xlU p,
        > row_num
        >
        > Inerop -->Interop
        >[/color]


        Comment

        • Tim Wallace

          #5
          Re: insert row to Excel using C#

          I still get the "Cannot shift objects off sheet" error. Any ideas?

          Tim

          "django" <lagwal@gmail.c om> wrote in message
          news:1128708181 .992873.214290@ g47g2000cwa.goo glegroups.com.. .[color=blue]
          > Your argument Microsoft.Offic e.Inerop.Excel. XlDirection.xlU p,
          > row_num
          >
          > Inerop -->Interop
          >[/color]


          Comment

          • carion1

            #6
            Re: insert row to Excel using C#

            Yes, if he defines a range. You can also use adox to change the schema
            without instantiating Excel. Office automation is evil.

            --

            Derek Davis
            ddavis76@gmail. com

            "Danny Tuppeny" <groups@dannytu ppeny.commmmmm> wrote in message
            news:4346b878$0 $15067$ed2619ec @ptn-nntp-reader02.plus.n et...[color=blue]
            > "Tim Wallace" <twallace-ThisDoesNotBelo ng-AT-emailDOTcom> wrote in message
            > news:OaDXoQ2yFH A.612@TK2MSFTNG P10.phx.gbl...[color=green]
            >>I need to insert a row into an Excel spreadsheet using C#. I get a
            >>reference to the app, the workbook, the sheet. When I attempt to call
            >>Insert, I keep getting errors, probably because I'm not certain what the
            >>args are (and cannot find any documentation to help). I supplied the 2
            >>args as I thought were correct (
            >>Microsoft.Off ice.Inerop.Exce l.XlDirection.x lUp, row_num ), but these don't
            >>seem correct. Can anyone please help or point me to a valid Web source?[/color]
            >
            > Can't you use ADO.NET with an Excel connection string instead? Then you
            > just use T-SQL INSERT statements :)
            >
            > http://www.c-sharpcorner.com/Code/20...essExcelDb.asp
            >
            >[/color]


            Comment

            Working...