Hullo Friends,
I do need your help. Please help me.
I am using C#NET 2008 to create Window Application to export data from SQL SERVER to Excel Spreadsheet.
I have not done that before and encounter an very interesting problem of HOW TO SAVE EXCEL SPREADSHEET onto the define FOLDER PATH
Here are the coding: using Microsoft.Office.Interop.Excel;
// --- Declare EXCEL Objects ---
Microsoft.Office.Interop.Excel.Application xlExcel = null;
Microsoft.Office.Interop.Excel.Workbook xlWrkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWrkSheet;
Microsoft.Office.Interop.Excel.Range xlRange;
Microsoft.Office.Interop.Excel.Range xlWrkSheet_Range;
// --- Instantiate EXCEL Object ---
xlExcel = new Microsoft.Office.Interop.Excel.Application();
xlWrkBook = xlExcel.Workbooks.Add(OMissing);
xlWrkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWrkBook.Worksheets.get_Item(1);
xlExcel.Visible = true;
while (DR.Read())
{
introw += 1;
xlWrkSheet.Cells[introw, 1] = DR["OrderID"];
xlWrkSheet.Cells[introw, 2] = DR["OrderDate"];
xlWrkSheet.Cells[introw, 3] = DR["RequiredDate"];
xlWrkSheet.Cells[introw, 4] = DR["ShipDate"];
xlWrkSheet.Cells[introw, 5] = DR["shipperName"]; // Shipper Name
xlWrkSheet.Cells[introw, 6] = DR["ProductName"];
xlWrkSheet.Cells[introw, 7] = DR["UnitPrice"];
xlWrkSheet.Cells[introw, 8] = DR["Discount"];
xlWrkSheet.Cells[introw, 9] = DR["ExtendedPrice"];
xlWrkSheet.Cells[introw, 10] = DR["Freight"];
} //end while
// --- Folder Path and Excel Name ---
string folderPath = "C:\ExcelFolder\;
string ExcelName = "Invoice.xls";
string FullName = folderPath + ExcelName
HOW TO SAVE THE FULLNAME ?
Thank you for your help. Appreciate that very much for helping me.
Cheers,
Lennie