launching excel from web form

Results 1 to 2 of 2

Thread: launching excel from web form

  1. #1
    Join Date
    Dec 1969

    Default launching excel from web form

    I have button and a datagrid on a web from. When the user clicks the button, I want to copy all the data in the datagrid into a new excel worksheet. I keep getting the error listed below. My button onclick handler is below that. I apparently need to ad the aspnet account to something but I&#039;m not sure what.<BR> <BR><BR>ERROR:<BR>Access is denied. <BR>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. <BR><BR>Exception Details: System.UnauthorizedAccessException: Access is denied. <BR><BR>The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is &#039;{machinename}ASPNET&#039;, which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity. <BR><BR>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 "{machinename}ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.<BR><BR>CODE: <BR> Dim application As New Excel.Application()<BR> Dim WorkBook As New Excel.Workbook()<BR> Dim worksheet As Excel.Worksheet<BR> Dim sheets As Excel.Worksheets<BR> Dim drRow As DataRow<BR> Dim i, j As Integer<BR> application = CreateObject("Excel.Application")<BR> application.Visible = True<BR> WorkBook = application.Workbooks.Add(Excel.XlWBATemplate.xlWB ATWorksheet)<BR> sheets = WorkBook.Sheets<BR> &#039;WorkBook.Worksheets()<BR> worksheet = CType(sheets.Item(1), Excel.Worksheet)<BR> For i = 1 To IterationTable.Rows.Count()<BR> drRow = IterationTable.Rows(i - 1)<BR> For j = 1 To drRow.ItemArray().GetLength(0)<BR> worksheet.Cells(i, j) = drRow.Item(j - 1)<BR> Next<BR> Next

  2. #2
    Join Date
    Dec 1969

    Default RE: launching excel from web form is tough on security.<BR><BR>you can launch excel through a user control(built using windows control library), though it&#039;s not easy.<BR><BR>set the necessary codes (as your code) to launch excel and print your report.<BR><BR>build the control, copy the DLL into the same directory as the web page and then attach the DLL to the page as an object(w. object ID and Class ID). <BR>ex. <BR>&#060;OBJECT id="OpenFileDialogObjectID" height="0" width="0" classid="http:OpenFile.dll#OpenFile.FileDialog" VIEWASTEXT&#062;<BR>&#060;/OBJECT&#062;<BR><BR>then go to the control panel and setup .NET Framework Configuration MMC to trust the assembly(DLL).<BR><BR>you can now launch excel.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts