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

  • SEARCH
  • Home
  • 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 89677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:45:14+00:00 2026-05-10T22:45:14+00:00

I am trying to send some data from a LINQ query in C# to

  • 0

I am trying to send some data from a LINQ query in C# to an Excel speed sheet using OLE

I have a query like this:

Var data = from d in db.{MyTable}            where d.Name = 'Test'            select d; 

I have the Excel OLE object working fine, I just can’t figure out how to populate the cells in Excel with the data from the LINQ query.

PS: I am using Excel 2003 if that makes any difference.

Can anyone help me with this?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:45:15+00:00Added an answer on May 10, 2026 at 10:45 pm

    Sending individual OLE commands for each Excel cell is very slow so the key is to create an object array like this:

    int noOfRows = data.Count - 1; int noOfColumns = mydataclass.GetType().GetProperties().Count() - 1; Object[noOfRows, noOfColumns] myArray; 

    Sending an object array allows you to send a mixture of data types e.g. string, integer, date etc. However, if you know that the data is all text for example, you can just send a string array.

    The array needs to be populated from the query either by assigning each individual value or perhaps by using reflection to get the data object properties. Then you can send the array to Excel like this:

    XLOLESheetobj.Range('A1','Z20').Value = myArray; 

    You can substitute Z20 with the number of columns -> Char + the number of rows -> string.

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

Sidebar

Related Questions

I'm using Grails 2.0.0, and trying to prepopulate some test data from Bootstrap.groovy. This
I am currently trying to send some data from and Android application to a
I'm trying to send some String Data from sub activity to main activity and
I am trying to get some data from the user and send it to
I am trying to get some data from the user and send it to
I'm trying to send some data from the server to the client, but the
I'm trying to send some data from a C++ server to a C# client.
I am trying to send/receive some data across 2 computers (mac, ubuntu) using a
I am trying to retrieve some data from a database using jQuery's $.getJSON method
I am trying to send some text in an email from my cocoa app

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.