Click here to Skip to main content
15,894,106 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am writing and saving the data to excel file in one excel sheet with the following code


C#
if (File.Exists(path1))
   File.Delete(path1);
int i = 1;

foreach (DataRow row in ds1.Tables[0].Rows)
{
   xlWorkSheet.Cells[i, 1] = row[2];
   i++;
}

xlWorkBook.SaveAs(path1, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlShared, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);



How can write data to 3 different excel sheets of same excel file????

Thanks
John
Posted
Updated 29-Nov-13 1:39am
v3
Comments
Aydin Homay 29-Nov-13 7:39am    
So what is your question ?
Richard MacCutchan 29-Nov-13 7:39am    
Create a new worksheet for each data set and add them to the workbook before saving it.

 
Share this answer
 
v3
Read this Article. It will help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900