Hari,
There is no solution that I could find out. The workaround for this is to
use the Excel Object and create an excel on the server itself, which will
have to be ultimately downloaded on the client. But this method has it's own
limitations.
Regards,
Hemant
"HARI PRASD BARU" wrote:
[color=blue]
> Hemant,
> We also having same issue with Export to Excel, tried all possible code
> solutions but didn't worked out,
> Curious to know if you would have got solution as you also facing same issue.
> Plz let me know if have any solution..
>
> "Hemant Sipahimalani" wrote:
>[color=green]
> > Jeff,
> > MIME settings are set up to open a file with xls in Excel sheet. This is
> > exactly what the code does. It is only when you try to save the file, the
> > "Save as Type" is a "Web Page" as opposed to "xls".
> > Is it possible to send across the link to the test report on your
> > application across to me? Curious to see how it works against my Test bed.
> > Thanks,
> > Hemant
> >
> >
> > "Jeff Dillon" wrote:
> >[color=darkred]
> > > I'm wondering if it's a mime type setting on your server..
> > >
> > > Jeff
> > >
> > > "Hemant Sipahimalani" <HemantSipahimalani@discussions.microsoft.com> wrote
> > > in message news:4270C9D1-CC5F-44F2-999D-157EB918A504@microsoft.com...
> > > > Jeff,
> > > > I have the following versions installed on my machine.
> > > > 1. Excel - Microsoft Excel 2003 (11.5612.5606)
> > > > 2. IE - 6.0.2900.2180 , SP2
> > > > Thanks,
> > > > Hemant
> > > >
> > > > "Jeff Dillon" wrote:
> > > >
> > > >> On ALL our machines, my code shows Save As Excel Sheet in the Save As
> > > >> dialog
> > > >> popup.
> > > >>
> > > >> Do you have Excel installed on your client machines?? Which is a
> > > >> requirement
> > > >> of course, to save in that format.
> > > >>
> > > >> Jeff
> > > >>
> > > >> "Hemant Sipahimalani" <HemantSipahimalani@discussions.microsoft.com>
> > > >> wrote
> > > >> in message news:E926C9C0-B95A-4D9D-9070-62261393E930@microsoft.com...
> > > >> > Jeff,
> > > >> > You are correct. The piece of code that you have written does show
> > > >> > the
> > > >> > Exported file as "Text (tab delimited) (*.txt) " in the "Save as type"
> > > >> > dropdown when the user tries to save the excel file.
> > > >> > However in my case the data is in tabular format as opposed to
> > > >> > "Hello
> > > >> > World".
> > > >> > The data that I am trying to export is similar to
> > > >> >
> > > >> > strHTML = "<table><tr><td>1</td><td>2</td><td>3</td></tr></table>"
> > > >> >
> > > >> > HttpContext.Current.Response.Clear()
> > > >> > HttpContext.Current.Response.Buffer = True
> > > >> > HttpContext.Current.Response.ContentType =
> > > >> > "application/vnd.ms-excel"
> > > >> > HttpContext.Current.Response.AddHeader("Content-disposition",
> > > >> > "attachment;filename=export.xls")
> > > >> > HttpContext.Current.Response.Charset = ""
> > > >> > HttpContext.Current.Response.Write(strHTML)
> > > >> > HttpContext.Current.Response.End()
> > > >> >
> > > >> > In this case when the user tries to save the exported excel the "Save
> > > >> > as
> > > >> > Type" drop down shows the type as a "Web Page". This is something that
> > > >> > I
> > > >> > am
> > > >> > trying to avoid.
> > > >> >
> > > >> > Thanks,
> > > >> > Hemant
> > > >> >
> > > >> >
> > > >> > "Jeff Dillon" wrote:
> > > >> >
> > > >> >> Put this all by itself in test.aspx:
> > > >> >>
> > > >> >> <%
> > > >> >>
> > > >> >> Response.Clear()
> > > >> >> Response.Buffer = True
> > > >> >> Response.ContentType = "application/vnd.ms-excel"
> > > >> >> Response.AddHeader("Content-disposition",
> > > >> >> "attachment;filename=export.xls")
> > > >> >> Response.Charset = ""
> > > >> >> Response.Write("Hello world")
> > > >> >> Response.End()
> > > >> >>
> > > >> >> %>
> > > >> >>
> > > >> >> "Hemant Sipahimalani" <HemantSipahimalani@discussions.microsoft.com>
> > > >> >> wrote
> > > >> >> in message news:8B0AFB73-21B3-42E6-B9A7-87B38E1207A9@microsoft.com...
> > > >> >> > Thanks Jeff ,
> > > >> >> > but this still does not show the default File Type as xls when
> > > >> >> > the
> > > >> >> > user
> > > >> >> > tries to save the file.
> > > >> >> > Hemant
> > > >> >> > "Jeff Dillon" wrote:
> > > >> >> >
> > > >> >> >> We have used this code:
> > > >> >> >>
> > > >> >> >> objHttpContext.Response.Clear()
> > > >> >> >> objHttpContext.Response.Buffer = True
> > > >> >> >> objHttpContext.Response.ContentEncoding = System.Text.Encoding.UTF8
> > > >> >> >> objHttpContext.Response.ContentType = "application/vnd.ms-excel"
> > > >> >> >> objHttpContext.Response.AddHeader("Content-disposition",
> > > >> >> >> "attachment;filename=export.xls")
> > > >> >> >> objHttpContext.Response.Charset = ""
> > > >> >> >>
> > > >> >> >> "Hemant Sipahimalani" <Hemant
> > > >> >> >>
Sipahimalani@discussions.microsoft.com>
> > > >> >> >> wrote
> > > >> >> >> in message
> > > >> >> >> news:C0FC2030-600D-4D1D-88FB-C06FFF0EE101@microsoft.com...
> > > >> >> >> > The following piece of code is being used to export HTML to
> > > >> >> >> > excel.
> > > >> >> >> >
> > > >> >> >> > HttpContext.Current.Response.ContentType =
> > > >> >> >> > "application/vnd.ms-excel"
> > > >> >> >> > HttpContext.Current.Response.AddHeader("content-disposition",
> > > >> >> >> > "attachment;filename=ABC.xls")
> > > >> >> >> > HttpContext.Current.Response.Write(strHTML)
> > > >> >> >> > HttpContext.Current.Response.End()
> > > >> >> >> >
> > > >> >> >> > However when the user tries to save it the Default File Type is
> > > >> >> >> > Web
> > > >> >> >> > Page(*.htm; *.html)
> > > >> >> >> > How do we change the Default File Type to Excel
> > > >> >> >>
> > > >> >> >>
> > > >> >> >>
> > > >> >>
> > > >> >>
> > > >> >>
> > > >>
> > > >>
> > > >>
> > >
> > >
> > >[/color][/color][/color]