Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to convert COM Object to string in asp.net web application

how to convert COM Object to string in asp.net web application

Scheduled Pinned Locked Moved C#
helpcsharpasp-netcomtutorial
7 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    narendrakumarp
    wrote on last edited by
    #1

    we are using microsoft Office 9.0 Library & COM namespace is OWC TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1]; While writting this code it is not converting to object to string but in reverse case it is working properly uploading to spreadsheet. //This is the Error Error: Cannot convert Object to String So pls convey this & let me know the solution for the above problem. I m using asp.net with c# coding. Thanking u, Naren. please help me

    A J 3 Replies Last reply
    0
    • N narendrakumarp

      we are using microsoft Office 9.0 Library & COM namespace is OWC TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1]; While writting this code it is not converting to object to string but in reverse case it is working properly uploading to spreadsheet. //This is the Error Error: Cannot convert Object to String So pls convey this & let me know the solution for the above problem. I m using asp.net with c# coding. Thanking u, Naren. please help me

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      Try this: TextBox1.Text = (string) xlsheet.ActiveSheet.Cells[i,1]; Best regards, Alexey.

      1 Reply Last reply
      0
      • N narendrakumarp

        we are using microsoft Office 9.0 Library & COM namespace is OWC TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1]; While writting this code it is not converting to object to string but in reverse case it is working properly uploading to spreadsheet. //This is the Error Error: Cannot convert Object to String So pls convey this & let me know the solution for the above problem. I m using asp.net with c# coding. Thanking u, Naren. please help me

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1].ToString(); Every object in .NET has a .ToString() method -- modified at 7:45 Friday 21st April, 2006

        N 1 Reply Last reply
        0
        • N narendrakumarp

          we are using microsoft Office 9.0 Library & COM namespace is OWC TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1]; While writting this code it is not converting to object to string but in reverse case it is working properly uploading to spreadsheet. //This is the Error Error: Cannot convert Object to String So pls convey this & let me know the solution for the above problem. I m using asp.net with c# coding. Thanking u, Naren. please help me

          A Offline
          A Offline
          alexey N
          wrote on last edited by
          #4

          All solutions are incorrect. Correct code: Excel.Range cell = (Excel.Range)m_workSheet.Cells[x + 2, y + 1]; string st = cell.Text.ToString(); Best regards, Alexey.

          N 1 Reply Last reply
          0
          • J J4amieC

            TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1].ToString(); Every object in .NET has a .ToString() method -- modified at 7:45 Friday 21st April, 2006

            N Offline
            N Offline
            narendrakumarp
            wrote on last edited by
            #5

            Hi Thanks for sending Reply. TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1].ToString(); & also TextBox1.Text = (string)xlsheet.ActiveSheet.Cells[i,1]; But i used this, its not working. Pls give any idea. Once again Thanking u, Naren please help me

            1 Reply Last reply
            0
            • A alexey N

              All solutions are incorrect. Correct code: Excel.Range cell = (Excel.Range)m_workSheet.Cells[x + 2, y + 1]; string st = cell.Text.ToString(); Best regards, Alexey.

              N Offline
              N Offline
              narendrakumarp
              wrote on last edited by
              #6

              Hi Alexey Thanks a lot for immediate reply. Its giving an exception as "Specified Cast is not valid". Now i m getting this problem. Thanking u, Naren please help me

              D 1 Reply Last reply
              0
              • N narendrakumarp

                Hi Alexey Thanks a lot for immediate reply. Its giving an exception as "Specified Cast is not valid". Now i m getting this problem. Thanking u, Naren please help me

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                I hardly ever do Office Interop, but the Cell[,] returns a Cell, which has, IIRC, a Value property, soooo...

                TextBox1.Text = xlsheet.ActiveSheet.Cells[i,1].Value.ToString();

                might be what you're looking for, or something very close to it. Dave Kreskowiak Microsoft MVP - Visual Basic

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups