File save when generating excel in ASP

Results 1 to 2 of 2

Thread: File save when generating excel in ASP

  1. #1
    Join Date
    Dec 1969

    Default File save when generating excel in ASP

    Hi all,<BR><BR>I have write the following coding and save it as file name "test3.asp", in order to generate a excel file. After I have run the ASP file in IE, although I can save the file "de.xls" in the directory, it prompts me out another file download messagebox, asking me whether I want to open or save another excel file named "test3.xls". I have tried to save the "test3.xls" file into local and open it, but it prompts me error "Unable to read file" and there is nothing inside "test3.xls"<BR><BR>Since I woule only need the "de.xls" file, is there any method, besides using FileSystemObject (i.e. without re-writing the codes), to generate an excel file but without prompting me confirmation message box? Thanks for help.<BR><BR>Tony<BR><BR><BR>&#060;%@LANGUAGE="VBS cript"%&#062;<BR>&#060;% Response.ContentType = "application/" %&#062;<BR>&#060;% <BR> Dim objExcelApp<BR> Set objExcelApp = CreateObject("Excel.Application")<BR><BR> Set objExcelBook = objExcelApp.workbooks.add<BR><BR> Set objExcelSheets = objExcelBook.Worksheets<BR> Set objExcelSheet = objExcelBook.Sheets(1)<BR><BR> objExcelSheet.Activate<BR> objExcelApp.Application.Visible = True<BR><BR> objExcelSheet.Cells(1,1).Value = "mum"<BR> objExcelSheet.Cells(1,2).Value = "dad"<BR><BR> objExcelApp.activeworkbook.SaveAs("C:InetPubwwwroo t empde.xls")<BR><BR> objExcelApp.Application.Quit<BR> Set objExcelApp = Nothing<BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default Well, you set the content type...

    ...of your ASP page to be an Excel document, but then you never send any Excel compatible data. Actually, you never send any data to the browser. Of course, if you save that to your computer, you won&#039;t be able to open it in Excel because it doesn&#039;t conatin anything.<BR><BR>After your code has set the content type, it still runs and saves the de.xls file to the C: drive of the web server, so this part still works.<BR><BR>If you remove the line where you set the content type, everything should be fine. The de.xls file gets written and your browser doesn&#039;t expect to receive Excel data, so it won&#039;t ask you to save or open the file.<BR><BR>Oliver.

Posting Permissions

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