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. Late Binding With Excel

Late Binding With Excel

Scheduled Pinned Locked Moved C#
wpfwcfhelpannouncement
1 Posts 1 Posters 0 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.
  • K Offline
    K Offline
    ksanju1000
    wrote on last edited by
    #1

    Hi, Here is the program for displaying simple text in excel using late binding. It checks at run time.This program works on all the version of Excel. I want to modfify this program. Can anybody help me to do that. I want to display All the rows and coulmns of Emp table This is very easy with early binding. I want to do that with late binding here is code Write this code inside button click event pls anybody modify I want to display table conntents Excel using late binding ---------------------------------------- object objApp_Late; object objBook_Late; object objBooks_Late; object objSheets_Late; object objSheet_Late; object objRange_Late; object[] Parameters; int intExcelPID; try { // Get the class type and instantiate Excel. Type objClassType; objClassType = Type.GetTypeFromProgID("Excel.Application"); objApp_Late = Activator.CreateInstance(objClassType); Process[] aProcesses=Process.GetProcessesByName("Excel"); // please remove the string variable string strProc="These are the processes running \n"; for (int i = 0; i <= aProcesses.GetUpperBound(0); i++) { intExcelPID = aProcesses[i].Id; strProc+=intExcelPID.ToString()+ " "; } //Get the workbooks collection. objBooks_Late = objApp_Late.GetType().InvokeMember( "Workbooks", BindingFlags.GetProperty, null, objApp_Late, null ); //Add a new workbook. objBook_Late = objBooks_Late.GetType().InvokeMember( "Add", BindingFlags.InvokeMethod, null, objBooks_Late, null ); //Get the worksheets collection. objSheets_Late = objBook_Late.GetType().InvokeMember( "Worksheets", BindingFlags.GetProperty, null, objBook_Late, null ); //Get the first worksheet. Parameters = new Object[1]; Parameters[0] = 1; objSheet_Late = objSheets_Late.GetType().InvokeMember( "Item", BindingFlags.GetProperty, null, objSheets_Late, Parameters ); //Get a range object that contains cell A1. Parameters = new Object[2]; Parameters[0] = "A1"; Parameters[1] = Missing.Value; objRange_Late = objSheet_Late.GetType().InvokeMember( "Range", BindingFlags.GetProperty, null, objSheet_Late, Parameters ); //Write "Hello, World!" in cell A1. Parameters = new Object[1]; Parameters[0] = "Hello, World!"; objRange_Late.GetType().InvokeMember( "Value", BindingFlags.SetProperty, null, objRange_Late, Parameters ); //Return control of Excel to the user

    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