1
Answer

VSTO 2010: Write data into Excel file

SinYee Foo

SinYee Foo

11y
1.7k
1
Hi, I am newbie for VSTO 2010. Now i am trying to generate the excel file with data from Sqlserver . I am using Linq to write the query...but, I stuck on that...
Please can anyone help me...?

this my code:

  Excel.Worksheet DemoWorkSheet = Globals.ThisWorkbook.Application.ActiveSheet as Excel.Worksheet;
            DemoVSTODataContext demo = new DemoVSTODataContext();
            var login = from emplist in demo.Logins
                          select emplist;

so now..how i continue my coding...?
Thanks for helping...
Answers (1)
0
Santhosh Kumar Jayaraman

Santhosh Kumar Jayaraman

NA 9.9k 2.2m 11y
If you want to import data to excel from sql server table, then you can directly do it in SQL server.



INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\testing.xls;', 
'SELECT Name, Department FROM [Sheet1$]') 
SELECT [Name], [Department] FROM employee
GO