The 'correct' way to generate Excel spreadsheets is through the use of Office Web Components . However, due to the licensing (see MSKB Article ) you cannot use them on a public internet site (as a client license for Office is needed for each user retrieving the document).
However, this can be overcome due to the fact that Excel recognises HTML code. You can therefore output HTML that can be opened in Excel:
First of all, set the content type and response header to make the browser handle it as an Excel spreadsheet.
ASP VBScript:
<%@Language="VBScript"%>
<%
Response.ContentType="application/vnd.ms-excel"
Response.AddHeader "content-disposition", "attachment; filename=ExcelFileName"
%>
ASP JScript:
<%@Language="JScript"%>
<%
Response.ContentType="application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=ExcelFileName");
%
Comments