کد:
[LEFT][COLOR=blue][FONT="]protected[/FONT][/COLOR][FONT="] [COLOR=blue]void[/COLOR] btnExcel_Click([COLOR=blue]object[/COLOR] sender, [COLOR=#2B91AF]EventArgs[/COLOR] e)[/FONT][/LEFT]
[LEFT][FONT="] {[/FONT][/LEFT]
[LEFT][FONT="] [COLOR=blue]string[/COLOR] sql = HiddenField_Sql.Value;[/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]ApplicationClass[/COLOR] excel = [COLOR=blue]new[/COLOR] Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]ApplicationClass[/COLOR]();[/FONT][/LEFT]
[LEFT][FONT="] excel.Visible = [COLOR=blue]true[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Workbook[/COLOR] workbook = excel.Workbooks.Add(Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]XlWBATemplate[/COLOR].xlWBATWorksheet);[/FONT][/LEFT]
[LEFT][FONT="] Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Sheets[/COLOR] sheets = workbook.Worksheets;[/FONT][/LEFT]
[LEFT][FONT="] Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Worksheet[/COLOR] mySheet = (Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Worksheet[/COLOR])sheets.get_Item([COLOR=#A31515]"Sheet1"[/COLOR]);[/FONT][/LEFT]
[LEFT][FONT="] mySheet.DisplayRightToLeft = [COLOR=blue]true[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Rows.Font.Name = [COLOR=#A31515]"tahoma"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Range[/COLOR] myRng;[/FONT][/LEFT]
[LEFT][FONT="] myRng = (Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Range[/COLOR])mySheet.get_Range([COLOR=#A31515]"A1"[/COLOR], [COLOR=#A31515]"G1"[/COLOR]);[/FONT][/LEFT]
[LEFT][FONT="] myRng.Merge([COLOR=blue]true[/COLOR]);[/FONT][/LEFT]
[LEFT][FONT="] myRng.Font.Bold = [COLOR=blue]true[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] myRng = (Microsoft.Office.Interop.Excel.[COLOR=#2B91AF]Range[/COLOR])mySheet.get_Range([COLOR=#A31515]"A2"[/COLOR], [COLOR=#A31515]"G2"[/COLOR]);[/FONT][/LEFT]
[LEFT][FONT="] myRng.Font.Bold = [COLOR=blue]true[/COLOR];[/FONT][/LEFT]
[LEFT][COLOR=green][FONT="] [/FONT][/COLOR][/LEFT]
[LEFT][COLOR=green][FONT="] [/FONT][/COLOR][/LEFT]
[LEFT][FONT="] [COLOR=blue]int[/COLOR] RowIndex = 1;[/FONT][/LEFT]
[LEFT][FONT="] [COLOR=blue]string[/COLOR] headerText;[/FONT][/LEFT]
[LEFT][FONT="] headerText = [COLOR=#A31515]"گزارشات لاگ من"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 1] = headerText;[/FONT][/LEFT]
[LEFT][FONT="] RowIndex++;[/FONT][/LEFT]
[LEFT][FONT="] [COLOR=blue]string[/COLOR] connStr = [COLOR=#2B91AF]ConfigurationManager[/COLOR].AppSettings[[COLOR=#A31515]"ConnectionString"[/COLOR]];[/FONT][/LEFT]
[LEFT][FONT="] [COLOR=#2B91AF]SqlConnection[/COLOR] sqlConn = [COLOR=blue]new[/COLOR] [COLOR=#2B91AF]SqlConnection[/COLOR](connStr);[/FONT][/LEFT]
[LEFT][FONT="] [COLOR=#2B91AF]SqlCommand[/COLOR] sqlCmnd = [COLOR=blue]new[/COLOR] [COLOR=#2B91AF]SqlCommand[/COLOR](sql, sqlConn);[/FONT][/LEFT]
[LEFT][FONT="] sqlConn.Open();[/FONT][/LEFT]
[LEFT][FONT="] [COLOR=#2B91AF]SqlDataReader[/COLOR] dr = sqlCmnd.ExecuteReader();[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 1] = [COLOR=#A31515]"نام"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 2] = [COLOR=#A31515]"تاریخ رزرو"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 3] = [COLOR=#A31515]"ساعت رزور"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 4] = [COLOR=#A31515]"برنامه غذایی"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 5] = [COLOR=#A31515]"قیمت غذا"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 6] = [COLOR=#A31515]"نام غذا"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 7] = [COLOR=#A31515]"وضعیت"[/COLOR];[/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] [COLOR=blue]while[/COLOR] (dr.Read())[/FONT][/LEFT]
[LEFT][FONT="] {[/FONT][/LEFT]
[LEFT][FONT="] RowIndex++;[/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 1] = dr[[COLOR=#A31515]"urName"[/COLOR]].ToString();[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 2] = dr[[COLOR=#A31515]"lgDate"[/COLOR]].ToString();[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 3] = dr[[COLOR=#A31515]"lgTime"[/COLOR]].ToString();[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 4] = dr[[COLOR=#A31515]"dyDate"[/COLOR]].ToString();[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 5] = [COLOR=blue]int[/COLOR].Parse(dr[[COLOR=#A31515]"dyMyPrice"[/COLOR]].ToString());[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 6] = dr[[COLOR=#A31515]"fdName"[/COLOR]].ToString();[/FONT][/LEFT]
[LEFT][FONT="] mySheet.Cells[RowIndex, 7] = [COLOR=blue]int[/COLOR].Parse(dr[[COLOR=#A31515]"lgStatus"[/COLOR]].ToString());[/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] [/FONT][/LEFT]
[LEFT][FONT="] }[/FONT][/LEFT]
[LEFT][FONT="] sqlConn.Close();[/FONT][/LEFT]
[FONT="] }[/FONT][FONT="][/FONT]
[FONT="] [/FONT]
[FONT="]وقتی از طریق سورس برنامه رو اجرا میکنم اجرا میشه و به من خروجی اکسل رو میده ولی وقتی برنامه رو روی سرور [/FONT][FONT="]publish [/FONT][FONT="] میکنم به من خطا میده[/FONT]
[FONT="] [/FONT]
[FONT="]تو اینترنت سرچ کردم و راه حل رو پیدا کردم.[/FONT]
[FONT="]من بر اساس فروم زیر اقدام کردم[/FONT]
[FONT="] [/FONT]
[FONT="]http://forums.asp.net/p/1303594/3068584.aspx[/FONT][FONT="][/FONT]
[FONT="] [/FONT]
[FONT="]ولی باز هم خطا میده و اجرا نمیشه[/FONT]
[FONT="] [/FONT]
[FONT="]با استفاده از این کد کاربر جاری مشخص میشود[/FONT]
[FONT="] [/FONT]
[FONT="]TextBox1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name;[/FONT][FONT="][/FONT]
[FONT="] [/FONT]
[FONT="]که برای [/FONT][FONT="] web application [/FONT][FONT="]من [/FONT]
[FONT="]NT AUTHORITY\NETWORK SERVICE[/FONT][FONT="][/FONT]
[FONT="]بود[/FONT]
[FONT="] [/FONT]
کسی میتونه راهنمایی کنه؟؟
