R
Ryan
Hello,
I generate an .xls file from an asp.net page. It works fine to open it with
Excel 2003. However, when I test it on a machine installed Excel 2007, it
pops up an alert message. I know we can get rid of the alert message by
modifying the client PC's registry with the following solution, but in our
case, it's not realistic.
Problem and solution :
Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site
http://blogs.msdn.com/vsofficedeveloper/pages/Excel-2007-Extension-Warning.aspx
QUESTION:
I have tried to let the output file extension name to be ".xlsx" to avoid
this message, but Excel 2007 still cannot open the.xlsx file.
So what will be the solution to generate xlsx file on the fly?
I have tried with both "content-type:"
response.ContentType= "application/vnd.ms-excel"
and
response.ContentType
="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
I also read this article:
http://blogs.msdn.com/vsofficedeveloper/pages/Office-2007-Open-XML-MIME-Types.aspx
Then, I made sure that I have both MIME type on my web server, but still
doesn't work.
1) .xls = application/ms-excel
2) .xlsx = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For reference, this is my code :
html.Append("<table border=""1"">")
html.Append("<tr bgcolor=""#CEE7FF"">")
html.Append("<th>" & HttpUtility.HtmlEncode("Priority") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Status") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Call Id") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Client") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Support Type") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Description") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("FRC") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Unit") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Assigned date") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Assigned time") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Resolved date") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Resolved time") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Assignee") & "</th>")
html.Append("</tr>")
html.Append("</table>")
Response.ClearContent()
Response.AddHeader("Content-Disposition:",
"attachment;filename=HeatReport.xlsx")
Response.ContentType =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.Write(html.ToString)
Response.End()
I think that even if I name my report with the .xlsx extension, it's not
recognised as a real .xlsx report. I guess something is missing.
Could you please let me know the good way to make this work?
Thanks
I generate an .xls file from an asp.net page. It works fine to open it with
Excel 2003. However, when I test it on a machine installed Excel 2007, it
pops up an alert message. I know we can get rid of the alert message by
modifying the client PC's registry with the following solution, but in our
case, it's not realistic.
Problem and solution :
Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site
http://blogs.msdn.com/vsofficedeveloper/pages/Excel-2007-Extension-Warning.aspx
QUESTION:
I have tried to let the output file extension name to be ".xlsx" to avoid
this message, but Excel 2007 still cannot open the.xlsx file.
So what will be the solution to generate xlsx file on the fly?
I have tried with both "content-type:"
response.ContentType= "application/vnd.ms-excel"
and
response.ContentType
="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
I also read this article:
http://blogs.msdn.com/vsofficedeveloper/pages/Office-2007-Open-XML-MIME-Types.aspx
Then, I made sure that I have both MIME type on my web server, but still
doesn't work.
1) .xls = application/ms-excel
2) .xlsx = application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For reference, this is my code :
html.Append("<table border=""1"">")
html.Append("<tr bgcolor=""#CEE7FF"">")
html.Append("<th>" & HttpUtility.HtmlEncode("Priority") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Status") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Call Id") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Client") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Support Type") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Description") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("FRC") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Unit") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Assigned date") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Assigned time") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Resolved date") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Resolved time") & "</th>")
html.Append("<th>" & HttpUtility.HtmlEncode("Assignee") & "</th>")
html.Append("</tr>")
html.Append("</table>")
Response.ClearContent()
Response.AddHeader("Content-Disposition:",
"attachment;filename=HeatReport.xlsx")
Response.ContentType =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.Write(html.ToString)
Response.End()
I think that even if I name my report with the .xlsx extension, it's not
recognised as a real .xlsx report. I guess something is missing.
Could you please let me know the good way to make this work?
Thanks