here is a code snippet from one of my apps..it works for me..
public void ExportToExcel(DataSet myDataSet) {
try {
// Export The Dataset passed to an Excel Spreadsheet.
Excel.Application oXL;
Excel.Workbook oWB;
Excel.Worksheet oSheet;
oXL = new Excel.ApplicationClass();
oXL.Visible = true;
oWB = (Excel.Workbook)(oXL.Workbooks.Add(Missing.Value)) ;
oSheet = (Excel.Worksheet)oWB.ActiveSheet;
oSheet.Name = "QueryBuilder Export";
oXL.WindowState = Excel.XlWindowState.xlMinimized;
// Initialise the progress form.
frmProgress newProgress = new frmProgress();
newProgress.pbProgress.Minimum = 1;
newProgress.pbProgress.Value = 1;
newProgress.pbProgress.Step = 1;
newProgress.Show();
foreach(DataTable table in myDataSet.Tables) {
// Set Maximum to the total number of files to copy.
newProgress.pbProgress.Maximum = table.Rows.Count;
int row = 1, column = 1;
// Need to export the column headers here.
foreach (object oH in table.Columns) {
oSheet.Cells[row, column] = oH.ToString();
column++;
}
row++;
foreach(DataRow r in table.Rows) {
column = 1;
foreach (object o in r.ItemArray) {
oSheet.Cells[row, column] = o.ToString();
column++;
}
row++;
newProgress.pbProgress.PerformStep();
Application.DoEvents();
}
}
newProgress.Close();
MessageBox.Show("Export Process has completed");
oXL.WindowState = Excel.XlWindowState.xlMaximized;
}
catch (Exception e) {
// Exception Handler
MessageBox.Show("Export Process has Errored : " + e.Message);
}
}
"Maria L." <an*******@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
thanks for your reply.
Actually, I am running Office 2000, so I will need to do it row by row.
What is the name of the libraries that I have to import?
Do you have any code snippet that might give me an idea?
I know the general idea, but I don't know where to start!
Maria