473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Export to Excel (Default File Type - Excel)

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
Apr 24 '06 #1
13 13170
Try putting a Response.Clear() line at the beggining of your code block.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Hemant Sipahimalani" <Hemant Si**********@discussions.microsoft.com> wrote
in message news:C0**********************************@microsof t.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

Apr 24 '06 #2
Steve,
Thank you for the prompt reply. Response.Clear does not help though.
Listing out the full piece of code for better clarity.

Dim strFileName As String
Dim strHTML As String
Dim strAddInfo As String

HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
strReportName = "EXPORT REPORT"
strFileName = "ABC.xls"
strAddInfo = "Additional Info"
strHTML = GetGHTML() 'This is responsible for getting report in HTML format
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=" & strFileName)
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.Write("<h4>" & strReportName & "</h4>")
HttpContext.Current.Response.Write(strAddInfo)
HttpContext.Current.Response.Write("<br><br>")
HttpContext.Current.Response.Write(strHTML)
HttpContext.Current.Response.End()
Hemant
"Steve C. Orr [MVP, MCSD]" wrote:
Try putting a Response.Clear() line at the beggining of your code block.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Hemant Sipahimalani" <Hemant Si**********@discussions.microsoft.com> wrote
in message news:C0**********************************@microsof t.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


Apr 25 '06 #3
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 Si**********@discussions.microsoft.com> wrote
in message news:C0**********************************@microsof t.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

Apr 25 '06 #4
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 Si**********@discussions.microsoft.com> wrote
in message news:C0**********************************@microsof t.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


Apr 26 '06 #5
Well, it does for us, for every browser in the company

Jeff
"Hemant Sipahimalani" <He****************@discussions.microsoft.com> wrote
in message news:8B**********************************@microsof t.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 Si**********@discussions.microsoft.com>
wrote
in message news:C0**********************************@microsof t.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


Apr 26 '06 #6
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" <He****************@discussions.microsoft.com> wrote
in message news:8B**********************************@microsof t.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 Si**********@discussions.microsoft.com>
wrote
in message news:C0**********************************@microsof t.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


Apr 26 '06 #7
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" <He****************@discussions.microsoft.com> wrote
in message news:8B**********************************@microsof t.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 Si**********@discussions.microsoft.com>
wrote
in message news:C0**********************************@microsof t.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


Apr 27 '06 #8
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" <He****************@discussions.microsoft.com> wrote
in message news:E9**********************************@microsof t.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" <He****************@discussions.microsoft.com>
wrote
in message news:8B**********************************@microsof t.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 Si**********@discussions.microsoft.com>
>> wrote
>> in message news:C0**********************************@microsof t.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
>>
>>
>>


Apr 27 '06 #9
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" <He****************@discussions.microsoft.com> wrote
in message news:E9**********************************@microsof t.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" <He****************@discussions.microsoft.com>
wrote
in message news:8B**********************************@microsof t.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 Si**********@discussions.microsoft.com>
>> wrote
>> in message news:C0**********************************@microsof t.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
>>
>>
>>


Apr 28 '06 #10
I'm wondering if it's a mime type setting on your server..

Jeff

"Hemant Sipahimalani" <He****************@discussions.microsoft.com> wrote
in message news:42**********************************@microsof t.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" <He****************@discussions.microsoft.com>
wrote
in message news:E9**********************************@microsof t.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" <He****************@discussions.microsoft.com>
>> wrote
>> in message news:8B**********************************@microsof t.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
>> >> Si**********@discussions.microsoft.com>
>> >> wrote
>> >> in message
>> >> news:C0**********************************@microsof t.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
>> >>
>> >>
>> >>
>>
>>
>>


Apr 28 '06 #11
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:
I'm wondering if it's a mime type setting on your server..

Jeff

"Hemant Sipahimalani" <He****************@discussions.microsoft.com> wrote
in message news:42**********************************@microsof t.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" <He****************@discussions.microsoft.com>
wrote
in message news:E9**********************************@microsof t.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" <He****************@discussions.microsoft.com>
>> wrote
>> in message news:8B**********************************@microsof t.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
>> >> Si**********@discussions.microsoft.com>
>> >> wrote
>> >> in message
>> >> news:C0**********************************@microsof t.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
>> >>
>> >>
>> >>
>>
>>
>>


May 5 '06 #12
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:
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:
I'm wondering if it's a mime type setting on your server..

Jeff

"Hemant Sipahimalani" <He****************@discussions.microsoft.com> wrote
in message news:42**********************************@microsof t.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" <He****************@discussions.microsoft.com>
> wrote
> in message news:E9**********************************@microsof t.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" <He****************@discussions.microsoft.com>
> >> wrote
> >> in message news:8B**********************************@microsof t.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
> >> >> Si**********@discussions.microsoft.com>
> >> >> wrote
> >> >> in message
> >> >> news:C0**********************************@microsof t.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
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>


Jun 19 '06 #13
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:
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:
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:
I'm wondering if it's a mime type setting on your server..

Jeff

"Hemant Sipahimalani" <He****************@discussions.microsoft.com> wrote
in message news:42**********************************@microsof t.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" <He****************@discussions.microsoft.com>
>> wrote
>> in message news:E9**********************************@microsof t.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" <He****************@discussions.microsoft.com>
>> >> wrote
>> >> in message news:8B**********************************@microsof t.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
>> >> >> Si**********@discussions.microsoft.com>
>> >> >> wrote
>> >> >> in message
>> >> >> news:C0**********************************@microsof t.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
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>

Jun 21 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hon Seng Phuah | last post by:
Hi all, I have a huge excel format file wants to export to sql server database. One of the field has combination of numeric and alphanumeric. When I import the excel format to sql server...
2
by: zino | last post by:
I have a file that is created in Excel and saved as an htm file. (if I open the file through Excel it open as Excel file, if I click on the file name it open in internet explorer). I need to...
6
by: Eric | last post by:
Dear All, I want to export datagrid content to a Excel file, the code just like below: Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim...
3
by: sam | last post by:
Can you teach me how to export access file to excel file in VB.net? Thank in advance.
0
by: Benny Ng | last post by:
Dear ALl, Now I want to export the crystal report to Excel file. But actually don't know how to export it with multiple sheet. Because sometime in some particular cases. It needs us to provided an...
0
by: Srikash74 | last post by:
Hi, I am using File Upload Control in ASP.NET (2.0). I would like to know is there any way we can filter the file type and show only the required files (e.g .html) in the open dialog control...
9
by: backups2007 | last post by:
please help. my code displays two errors that I'm having a hard time to resolve. here are the errors: first is: missing name in export statement; it generates an excel file. but this error...
0
by: JFKJr | last post by:
Hello everyone! I am trying to export Access table data into Excel file in such a way that the table field names should be in the first line of each column in excel file followed by field data, and...
0
by: vivek kapile | last post by:
Language: ASP.net Platform: Visual Studio 2008 with ASP.net Technology: Used in ASP.net Introduction 1. Add a gridview into a aspx file 2. Add a button into a aspx file and give the name as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.