|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dynamic XLSX files from a web pageI 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("</tr>")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("</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 -- Ryan Hi Ryan,
Thanks for your posting. Since the question you mentioned is an ASP.NET web application issue, I would suggest you post in the those ASP.NET specific newsgroups in the future: microsoft.public.dotnet.framework.aspnet As for the problem you mentioned here, I think it is due to the content you write out in ASP.NET page is in HTML format instead of the expected xls or xlsx (excel native format) content. And excel 2007 program is abit more restrict on such format and result to the prompt dialog. I'm afraid such kind of HTML or csv like format data cannot bypass the format validation(and the warning). BTW, for office 2007 document, you can use the OOXML sdk to programmtically generate the document that conform the format: #Getting Started with the Open XML Format SDK 2.0 http://msdn.microsoft.com/en-us/library/bb456488(office.14).aspx http://msdn.microsoft.com/en-us/office/bb265236.aspx Sincerely, Steven Cheng Microsoft MSDN Online Support Lead Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msd***@microsoft.com. ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications. -------------------- Show quoteHide quote >Thread-Topic: dynamic XLSX files from a web page http://blogs.msdn.com/vsofficedeveloper/pages/Excel-2007-Extension-Warning.a>thread-index: AcnDpIQHsFlueoQbQaq4UTTDZrASdg== >X-WBNR-Posting-Host: 72.136.156.124 >From: =?Utf-8?B?Unlhbg==?= <weeims@nospam.nospam> >Subject: dynamic XLSX files from a web page >Date: Wed, 22 Apr 2009 16:46:11 -0700 > >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 > spx Show quoteHide quote > http://blogs.msdn.com/vsofficedeveloper/pages/Office-2007-Open-XML-MIME-Type>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: > s.aspx > application/vnd.openxmlformats-officedocument.spreadsheetml.sheet>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 = Show quoteHide quote > >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() >-- >Ryan >
Other interesting topics
Re: server side redirect https => http STILL NOT working
ASP (not asp.net) How to redirect after ALERT. Sorting like Amazon DVD system ignore style History.go with asp. Behavior of ADODB.Command .Execute changes on different servers??? Re: Looking up ISP domains from IP addresses Is ASP programming still supported in latest visual studio? ASP.Net 2.0 Excel app requires MS Office on webserver |
|||||||||||||||||||||||