Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, what is the best way for me to export the results from this query into an excel sheet?
C#
private void btnDownload_Click(object sender, EventArgs e)
        {
            var queryResult = from s in context.Contacts
                              join c in context.Address on s.ContactID equals c.Contact.ContactID
                              select new
                              {
                                  s.FirstName,
                                  s.LastName,
                                  s.ContactNumber,
                                  s.Address,
                                  c.Address1,
                                  c.Mortgage,
                                  c.RemainingMortgage,
                                  c.Rent,
                                  c.Period,
                                  c.RentArrears,
                                  c.Rates,
                                  c.RateArrears,
                                  c.RatesUpToDate,
                                  c.Repairs
                              };
        }
Posted

1 solution

Use MS Office PIA's Primary Interop Libraries to export your data in excel format
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900