帮助将Linq导出到实体查询结果到Excel [英] Help exporting Linq to Entity query results to Excel
本文介绍了帮助将Linq导出到实体查询结果到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将这个查询的结果导出到Excel工作表的最佳方法是什么?
Hi, what is the best way for me to export the results from this query into an excel sheet?
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
};
}
推荐答案
使用MS Office PIA的主互操作库以excel格式导出数据
Use MS Office PIA's Primary Interop Libraries to export your data in excel format
>
这篇关于帮助将Linq导出到实体查询结果到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文