This topic is locked

Launching Excel file using ASP

9/15/2006 1:40:22 PM
ASPRunnerPro General questions
skemp author

Hi,
I am trying to find a means to open an excel file with information that gets embedded based upon the record information selected by the user.
I was thinking that perhaps I could use the 'view' link on a record that would open an excel file (empty) and fill it with the values found in the selected record from the listing. (this is all an effort to create and use preprinted forms in an application.
Any help at all is greatly appreciated!!
Sheryl

Admin 9/18/2006

Sheryl,
try to add the following in the beginning of the View page (..._view.asp):
Response.ContentType = "application/vnd.ms-excel"

Response.AddHeader "Content-Disposition", "attachment; Filename=RecordView.xls"

Response.Write "<html xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:x=""urn:schemas-microsoft-com:office:excel"" xmlns=""http://www.w3.org/TR/REC-html40"">";

Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=Windows-1252"">"
If this works you can remove unnecessary links and labels from that page that you don't want to see in Excel file.

skemp author 9/18/2006

Sheryl,

try to add the following in the beginning of the View page (..._view.asp):
Response.ContentType = "application/vnd.ms-excel"

Response.AddHeader "Content-Disposition", "attachment; Filename=RecordView.xls"

Response.Write "<html xmlns:o=""urn:schemas-microsoft-com:office:office"" xmlns:x=""urn:schemas-microsoft-com:office:excel"" xmlns=""http://www.w3.org/TR/REC-html40"">";

Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=Windows-1252"">"
If this works you can remove unnecessary links and labels from that page that you don't want to see in Excel file.


Thank you, that certainly helps! Is there any way to insert the data into certain cells inside of the excel spreadsheet?

Hi,

I am trying to find a means to open an excel file with information that gets embedded based upon the record information selected by the user.
I was thinking that perhaps I could use the 'view' link on a record that would open an excel file (empty) and fill it with the values found in the selected record from the listing. (this is all an effort to create and use preprinted forms in an application.
Any help at all is greatly appreciated!!
Sheryl


Thank you, that helps a lot! Is there any way to insert the data into certain cells of the spreadsheet?

Admin 9/18/2006

Sheryl,
HTML cells are treated as cell in Excel. Basically you need to have an HTML table with labels and cell data.
If you modify existing view page you need to remove unnecessary "Back to list" links.

skemp author 9/25/2006

Sheryl,

HTML cells are treated as cell in Excel. Basically you need to have an HTML table with labels and cell data.
If you modify existing view page you need to remove unnecessary "Back to list" links.


Just prior to the excel file opening it gives me this error message:
"Missing file...Temporary Interenet Files\Content.IE5\OXQFWPOB\style.css"
It then opens excel with the file name given but none of the pre-formatting is in the file, it looks as if it overwrote everything I previously had in the file and replaced it with the information from the selected record. Is there anything I can do about this?

Admin 9/25/2006

I guess you need to move style definitions from style.css file to view.asp.
Make sure you add style wrappers before and after:
<style>
content from style.css goes here
</style>