Visual Studio 2012 for Windows Desktop Microsoft SQL Server 2008 Excel 2007
I have created a desktop application for data entry into a SQL database using databinding. I now need to create a report to extract this information from the SQL database from the client side of the application in the form of an excel workbook.
My question is: How can I export all columns from a SQL view into an excel workbook from my desktop application?
I have the ground work below, but not sure how to put the view data into the worksheet.
private void button_Click(object sender, EventArgs e)
{
try
{
Excel.Application oXL = new Excel.Application();
oXL.Visible = true;
Excel.Workbook oWB = oXL.Workbooks.Add();
Excel.Worksheet oSheet = oWB.ActiveSheet;
oSheet.Cells[1, 1] = "Hello World!";
}
catch (Exception ex)
{
MessageBox.Show("Error");
}
}