Last post Apr 12, 2012 02:20 AM by dineshchaudhari
Member
145 Points
124 Posts
Apr 12, 2012 01:38 AM|dineshchaudhari|LINK
Hi guys,
my requirement is need to genarte xls file in which i need data in mltiple timesheets.
i am able to genrate this file and file genrate correct but the application does not stop it keep running. pls help me on this
my code is.....
DataSet dataset; dataset = DB.GetDataSet("usp_rpt_ProjectTimesheet '','','A'"); Excel.Application excel = new Excel.Application(); var workbook = (Excel._Workbook)(excel.Workbooks.Add(Missing.Value)); for (var i = 0; i < dataset.Tables.Count; i++) { if (workbook.Sheets.Count <= i) { workbook.Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing); } //NOTE: Excel numbering goes from 1 to n var currentSheet = (Excel._Worksheet)workbook.Sheets[i + 1]; switch(Convert.ToInt32(i)) { case 0: currentSheet.Name = "Projects"; break; case 1: currentSheet.Name = "Employee"; break; } for (var j = 0; j < dataset.Tables[i].Columns.Count; j++) { currentSheet.Cells[1, j + 1] = dataset.Tables[i].Columns[j].ToString(); } for (var y = 0; y < dataset.Tables[i].Rows.Count; y++) { for (var x = 0; x < dataset.Tables[i].Rows[y].ItemArray.Count(); x++) { currentSheet.Cells[y + 2, x + 1] = dataset.Tables[i].Rows[y].ItemArray[x]; } } } workbook.SaveCopyAs(Server.MapPath("rpt.xlsx")); /*workbook.SaveAs(Server.MapPath("EXCEL_TEST.xlsx"), Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);*/ workbook.Close(true, Type.Missing, Type.Missing); excel.Quit();
Thanks in advance
Apr 12, 2012 02:20 AM|dineshchaudhari|LINK
I found the EXCEL.EXE is running in task manager....
when i click on end process, then my application gets stop......
pls help me to turn around this .....
Member
145 Points
124 Posts
PLs help urgent
Apr 12, 2012 01:38 AM|dineshchaudhari|LINK
Hi guys,
my requirement is need to genarte xls file in which i need data in mltiple timesheets.
i am able to genrate this file and file genrate correct but the application does not stop it keep running. pls help me on this
my code is.....
Thanks in advance
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
Member
145 Points
124 Posts
Re: PLs help urgent
Apr 12, 2012 02:20 AM|dineshchaudhari|LINK
I found the EXCEL.EXE is running in task manager....
when i click on end process, then my application gets stop......
pls help me to turn around this .....
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.