473,245 Members | 1,338 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,245 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 13155
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.