Handling Excel Files...
-
Hi to All, I am trying to handle excel file in my application. Here I am trying to get a cell value in the text box on the event of button click. but whenever i run it shows exception that Access is denied..... my code is as follows.... private Excel.Application oXL=null; private void Button1_Click(object sender, System.EventArgs e) { InitializeComponent(); oXL = new Excel.ApplicationClass(); oXL.Visible = true; Excel.Workbook oWB = oXL.Workbooks.Open("D:\\Pravin\\October-07\\xls\\7starcare-October.xls",0,true,5,"","",true,Excel.XlPlatform.xlWindows,"\t",false, false, 0, true); Excel.Sheets oSheet= oWB.Worksheets; Excel.Worksheet oWS = (Excel.Worksheet)oSheet.get_Item(1); TextBox1.Text= Convert.ToString(oWS.Cells.get_Item(1,1)); } But whenever i run my application it shows exception as follws .... ------------------------------------------------------------------------------------------------ Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access. ---------------------------------------------------------------------------------------------------- how can i remove this problem?
Pravin
-
Hi to All, I am trying to handle excel file in my application. Here I am trying to get a cell value in the text box on the event of button click. but whenever i run it shows exception that Access is denied..... my code is as follows.... private Excel.Application oXL=null; private void Button1_Click(object sender, System.EventArgs e) { InitializeComponent(); oXL = new Excel.ApplicationClass(); oXL.Visible = true; Excel.Workbook oWB = oXL.Workbooks.Open("D:\\Pravin\\October-07\\xls\\7starcare-October.xls",0,true,5,"","",true,Excel.XlPlatform.xlWindows,"\t",false, false, 0, true); Excel.Sheets oSheet= oWB.Worksheets; Excel.Worksheet oWS = (Excel.Worksheet)oSheet.get_Item(1); TextBox1.Text= Convert.ToString(oWS.Cells.get_Item(1,1)); } But whenever i run my application it shows exception as follws .... ------------------------------------------------------------------------------------------------ Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access. ---------------------------------------------------------------------------------------------------- how can i remove this problem?
Pravin