Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:15:50+00:00 2026-06-04T23:15:50+00:00

I’ve been looking at the microsoft support page Binding for Office automation servers with

  • 0

I’ve been looking at the microsoft support page Binding for Office automation servers with Visual C# .NET to try to create an Excel Worksheet, populate it with values in a datatable, and save it to the machine.

I have an implementation that uses early-binding and simply loops through the items, but I don’t know how you would achieve this with late-binding, and I need to be able to embed the Interop types to make the application version independent in regard to MS Office.

How would I add the rows from a datatable to a new Excel Worksheet using late-binding?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:15:53+00:00Added an answer on June 4, 2026 at 11:15 pm

    I would recommend writing an interface and abstracting the data population step, and the excel step. That way you can have a system that implements early binding with excel to do things, and then an engine that uses this interface to populate the excel sheet. Step 2 would be to write a second implementation of the interface using Late Binding rather than early binding. Then you just substitute the second implementation for the first in your code when you create the interface.

    In the code, you would only create 1 object, the interface itself. When creating it though, you can assign it as any other class/implementation that implements that interface…here’s an example from my own code:

    ISpreadsheetControl SSInterface;
    if (conditionCheck())
        SSInterface = new ExcelImplementer();
    else
        SSInterface = new OpenOfficeImplementer();
    

    I Only ever use the 1 object, SSInterface, when placing data or changing page settings, etc etc…whatever else I implemented…but it can do so in two different manners based on which Class I assigned to the interface at load time.

    As for the specifics and details on “how to”…I find the second example in the link you provided to be very helpful indeed. Its all about Type and Invoke. The difficulty will be keeping track of what you are working with at any given time. That is one of the things that will make it harder to work with, and a good reason to extract the early binding implementation first. That way you can see all the method names you will need and their parameter lists when writing the second.

    I also want to add this: The very simple and short answer to your question is “Do it exactly the same way you already are” You just change ‘how’ you are calling the method that is populating the data…and all the rest of the excel interop implementation along with it.

    UPDATE

    I think this might do what you are looking for, although its messy enough that I would recommend putting it (both operations actually, one can call the other) into its own separate method, somewhere.

    //Get a range object that contains the cell.
    Parameters = new Object[2];
    Parameters[0] = iRow + 1;
    Parameters[1] = iCol;
    objRange_Late = objSheet_Late.GetType().InvokeMember( "Cells",
        BindingFlags.GetProperty, null, objSheet_Late, Parameters );
    
    //Write value in cell
    Parameters = new Object[1];
    Parameters[0] = row[col.ColumnName];
    objRange_Late.GetType().InvokeMember( "Value", BindingFlags.SetProperty, 
        null, objRange_Late, Parameters );
    

    I have to admit, I don’t have an implementation that I can test this on right now, but according to the things I know about it, that should work. If “Cells” doesn’t work, I would also the same code with “Range”…I dont actually know if that one takes numerical input or not.

    link to Cells property description (msdn)

    you might also want to explore that whole system a bit, it can help you find some of the things you might be looking for.

    Tested Managed to successfully create and test the above code, it works perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.