Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Export to Excel 2007

Hi All,
I have an web application where user can export the results of search action
to an excel file so he can locally store it.. I have done this with very
simple code which is
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("content-disposition", "attachment;
filename=StackRanking.xls");
Response.Charset = "";
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new
System.Web.UI.HtmlTextWriter(sw);
(........fils dataset..... hw.RenderBeginTag)
(System.Web.UI.HtmlTextWriterTag.Html);
dg.RenderControl(hw);
hw.RenderEndTag();
Response.Write(sw);
Response.End();

All work fine when end user has Excel 2003 but when he has Excel 2007 it
gives a warning err message when he tries to open the rendered (downloaded)
Excel File,
I guess i need framework 3.0 to Support the file format of Excel 2007. What
in the code needs to be changed to have compatibility with Excel 2007
File.....

Thanks for reading my query...
--
Software Engineer

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Export to Excel 2007

I'm not a .Net developer but I'd guess your code creates a text file. Excel
2007 is equally capable of opening a text file as Excel 2003 so that
shouldn't be a problem. Even if your code creates an Excel 2003 files
(.XLS) Excel 2007 can open that too.

So I don't know what the problem is, but a clue would probably be found in
the exact text of the error message which you should have included in your
message.

--
Jim
"Amitabh" wrote in message
...
| Hi All,
| I have an web application where user can export the results of search
action
| to an excel file so he can locally store it.. I have done this with very
| simple code which is
| Response.ContentType = "application/vnd.ms-excel";
| Response.AppendHeader("content-disposition", "attachment;
| filename=StackRanking.xls");
| Response.Charset = "";
| System.IO.StringWriter sw = new System.IO.StringWriter();
| System.Web.UI.HtmlTextWriter hw = new
| System.Web.UI.HtmlTextWriter(sw);
| (........fils dataset..... hw.RenderBeginTag)
| (System.Web.UI.HtmlTextWriterTag.Html);
| dg.RenderControl(hw);
| hw.RenderEndTag();
| Response.Write(sw);
| Response.End();
|
| All work fine when end user has Excel 2003 but when he has Excel 2007 it
| gives a warning err message when he tries to open the rendered
(downloaded)
| Excel File,
| I guess i need framework 3.0 to Support the file format of Excel 2007.
What
| in the code needs to be changed to have compatibility with Excel 2007
| File.....
|
| Thanks for reading my query...
| --
| Software Engineer
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Export to Excel 2007

Thanks Jim for reply,
Yeah sorry Jim I forgot to give the Error Message. Below is the Error
message.

The file your are trying to open, "StackRanking.xls, is in a different
format than specified by the file extension. Verify that the file is not
corrupted and is from a trusted source before opening the file. Do you want
to open the file now?
and with three Command Buttons viz.. Yes, No, Help..

On hitting yes everything goes smoothly and opens correctly but the above
error message may confuse our clients...so I'm lookin for a way to avoid the
above error message.

And yes Jim, the code creates a HTML Text file I'll give you a little glance
of it when open that XLS file in notepad

<html
<table cellspacing="0" rules="all" border="1"
style="border-collapse:collapse;"
<tr<tdProposalId</td</tr
<tr<td11070</td</tr
</table
</html
--
Software Engineer,
Cybage Software Pvt. Ltd.
Pune, India


"Jim Rech" wrote:

I'm not a .Net developer but I'd guess your code creates a text file. Excel
2007 is equally capable of opening a text file as Excel 2003 so that
shouldn't be a problem. Even if your code creates an Excel 2003 files
(.XLS) Excel 2007 can open that too.

So I don't know what the problem is, but a clue would probably be found in
the exact text of the error message which you should have included in your
message.

--
Jim
"Amitabh" wrote in message
...
| Hi All,
| I have an web application where user can export the results of search
action
| to an excel file so he can locally store it.. I have done this with very
| simple code which is
| Response.ContentType = "application/vnd.ms-excel";
| Response.AppendHeader("content-disposition", "attachment;
| filename=StackRanking.xls");
| Response.Charset = "";
| System.IO.StringWriter sw = new System.IO.StringWriter();
| System.Web.UI.HtmlTextWriter hw = new
| System.Web.UI.HtmlTextWriter(sw);
| (........fils dataset..... hw.RenderBeginTag)
| (System.Web.UI.HtmlTextWriterTag.Html);
| dg.RenderControl(hw);
| hw.RenderEndTag();
| Response.Write(sw);
| Response.End();
|
| All work fine when end user has Excel 2003 but when he has Excel 2007 it
| gives a warning err message when he tries to open the rendered
(downloaded)
| Excel File,
| I guess i need framework 3.0 to Support the file format of Excel 2007.
What
| in the code needs to be changed to have compatibility with Excel 2007
| File.....
|
| Thanks for reading my query...
| --
| Software Engineer
|



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Export to Excel 2007

Ahh, yes Excel 2007 'protects' users from opening files that do not have the
format that their file extensions suggest. If the file is an HTML file any
reason not to give it the HTM extension?

--
Jim
"Amitabh" wrote in message
...
| Thanks Jim for reply,
| Yeah sorry Jim I forgot to give the Error Message. Below is the Error
| message.
|
| The file your are trying to open, "StackRanking.xls, is in a different
| format than specified by the file extension. Verify that the file is not
| corrupted and is from a trusted source before opening the file. Do you
want
| to open the file now?
| and with three Command Buttons viz.. Yes, No, Help..
|
| On hitting yes everything goes smoothly and opens correctly but the above
| error message may confuse our clients...so I'm lookin for a way to avoid
the
| above error message.
|
| And yes Jim, the code creates a HTML Text file I'll give you a little
glance
| of it when open that XLS file in notepad
|
| <html
| <table cellspacing="0" rules="all" border="1"
| style="border-collapse:collapse;"
| <tr<tdProposalId</td</tr
| <tr<td11070</td</tr
| </table
| </html
| --
| Software Engineer,
| Cybage Software Pvt. Ltd.
| Pune, India
|
|
| "Jim Rech" wrote:
|
| I'm not a .Net developer but I'd guess your code creates a text file.
Excel
| 2007 is equally capable of opening a text file as Excel 2003 so that
| shouldn't be a problem. Even if your code creates an Excel 2003 files
| (.XLS) Excel 2007 can open that too.
|
| So I don't know what the problem is, but a clue would probably be found
in
| the exact text of the error message which you should have included in
your
| message.
|
| --
| Jim
| "Amitabh" wrote in message
| ...
| | Hi All,
| | I have an web application where user can export the results of search
| action
| | to an excel file so he can locally store it.. I have done this with
very
| | simple code which is
| | Response.ContentType = "application/vnd.ms-excel";
| | Response.AppendHeader("content-disposition", "attachment;
| | filename=StackRanking.xls");
| | Response.Charset = "";
| | System.IO.StringWriter sw = new System.IO.StringWriter();
| | System.Web.UI.HtmlTextWriter hw = new
| | System.Web.UI.HtmlTextWriter(sw);
| | (........fils dataset..... hw.RenderBeginTag)
| | (System.Web.UI.HtmlTextWriterTag.Html);
| | dg.RenderControl(hw);
| | hw.RenderEndTag();
| | Response.Write(sw);
| | Response.End();
| |
| | All work fine when end user has Excel 2003 but when he has Excel 2007
it
| | gives a warning err message when he tries to open the rendered
| (downloaded)
| | Excel File,
| | I guess i need framework 3.0 to Support the file format of Excel 2007.
| What
| | in the code needs to be changed to have compatibility with Excel 2007
| | File.....
| |
| | Thanks for reading my query...
| | --
| | Software Engineer
| |
|
|
|


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Export to Excel 2007

Yep Jim, I tired it by changing Extension and Excel 2007 can open it without
any error but I have to first save it and then manually open it in Excel 2007
becaues by default .htm Extension are associated with IE and on directly
opening, it opens up in IE.
Jim, If there is any way to force from Server Application to directly open
file in Excel 2007, then it would solve the query.

Cindy Meister (Word MVP) Suggested me an alternative and I am working on it
too.
Please folloiw the link for her solution.
http://forums.microsoft.com/MSDN/sho...69919&siteid=1

--
Software Engineer,
Cybage Software Pvt. Ltd.
Pune, India


"Jim Rech" wrote:

Ahh, yes Excel 2007 'protects' users from opening files that do not have the
format that their file extensions suggest. If the file is an HTML file any
reason not to give it the HTM extension?

--
Jim
"Amitabh" wrote in message
...
| Thanks Jim for reply,
| Yeah sorry Jim I forgot to give the Error Message. Below is the Error
| message.
|
| The file your are trying to open, "StackRanking.xls, is in a different
| format than specified by the file extension. Verify that the file is not
| corrupted and is from a trusted source before opening the file. Do you
want
| to open the file now?
| and with three Command Buttons viz.. Yes, No, Help..
|
| On hitting yes everything goes smoothly and opens correctly but the above
| error message may confuse our clients...so I'm lookin for a way to avoid
the
| above error message.
|
| And yes Jim, the code creates a HTML Text file I'll give you a little
glance
| of it when open that XLS file in notepad
|
| <html
| <table cellspacing="0" rules="all" border="1"
| style="border-collapse:collapse;"
| <tr<tdProposalId</td</tr
| <tr<td11070</td</tr
| </table
| </html
| --
| Software Engineer,
| Cybage Software Pvt. Ltd.
| Pune, India
|
|
| "Jim Rech" wrote:
|
| I'm not a .Net developer but I'd guess your code creates a text file.
Excel
| 2007 is equally capable of opening a text file as Excel 2003 so that
| shouldn't be a problem. Even if your code creates an Excel 2003 files
| (.XLS) Excel 2007 can open that too.
|
| So I don't know what the problem is, but a clue would probably be found
in
| the exact text of the error message which you should have included in
your
| message.
|
| --
| Jim
| "Amitabh" wrote in message
| ...
| | Hi All,
| | I have an web application where user can export the results of search
| action
| | to an excel file so he can locally store it.. I have done this with
very
| | simple code which is
| | Response.ContentType = "application/vnd.ms-excel";
| | Response.AppendHeader("content-disposition", "attachment;
| | filename=StackRanking.xls");
| | Response.Charset = "";
| | System.IO.StringWriter sw = new System.IO.StringWriter();
| | System.Web.UI.HtmlTextWriter hw = new
| | System.Web.UI.HtmlTextWriter(sw);
| | (........fils dataset..... hw.RenderBeginTag)
| | (System.Web.UI.HtmlTextWriterTag.Html);
| | dg.RenderControl(hw);
| | hw.RenderEndTag();
| | Response.Write(sw);
| | Response.End();
| |
| | All work fine when end user has Excel 2003 but when he has Excel 2007
it
| | gives a warning err message when he tries to open the rendered
| (downloaded)
| | Excel File,
| | I guess i need framework 3.0 to Support the file format of Excel 2007.
| What
| | in the code needs to be changed to have compatibility with Excel 2007
| | File.....
| |
| | Thanks for reading my query...
| | --
| | Software Engineer
| |
|
|
|





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Export to Excel 2007

Sorry so slow to respond to you.

I have one workaround you might consider. The warning you get opening in
Excel 2007 is controlled by a registry entry that is read just when a file
is opened in Excel. So you could set the entry, open the file and reset the
registry back.

HKCU\Software\Microsoft\Office\12.0\Excel\Security \ExtensionHardening

Set this to 0 to bypass warning. Set to 1 or delete to re-establish the
warning.


--
Jim
"Amitabh" wrote in message
...
| Yep Jim, I tired it by changing Extension and Excel 2007 can open it
without
| any error but I have to first save it and then manually open it in Excel
2007
| becaues by default .htm Extension are associated with IE and on directly
| opening, it opens up in IE.
| Jim, If there is any way to force from Server Application to directly open
| file in Excel 2007, then it would solve the query.
|
| Cindy Meister (Word MVP) Suggested me an alternative and I am working on
it
| too.
| Please folloiw the link for her solution.
| http://forums.microsoft.com/MSDN/sho...69919&siteid=1
|
| --
| Software Engineer,
| Cybage Software Pvt. Ltd.
| Pune, India
|
|
| "Jim Rech" wrote:
|
| Ahh, yes Excel 2007 'protects' users from opening files that do not have
the
| format that their file extensions suggest. If the file is an HTML file
any
| reason not to give it the HTM extension?
|
| --
| Jim
| "Amitabh" wrote in message
| ...
| | Thanks Jim for reply,
| | Yeah sorry Jim I forgot to give the Error Message. Below is the Error
| | message.
| |
| | The file your are trying to open, "StackRanking.xls, is in a different
| | format than specified by the file extension. Verify that the file is
not
| | corrupted and is from a trusted source before opening the file. Do you
| want
| | to open the file now?
| | and with three Command Buttons viz.. Yes, No, Help..
| |
| | On hitting yes everything goes smoothly and opens correctly but the
above
| | error message may confuse our clients...so I'm lookin for a way to
avoid
| the
| | above error message.
| |
| | And yes Jim, the code creates a HTML Text file I'll give you a little
| glance
| | of it when open that XLS file in notepad
| |
| | <html
| | <table cellspacing="0" rules="all" border="1"
| | style="border-collapse:collapse;"
| | <tr<tdProposalId</td</tr
| | <tr<td11070</td</tr
| | </table
| | </html
| | --
| | Software Engineer,
| | Cybage Software Pvt. Ltd.
| | Pune, India
| |
| |
| | "Jim Rech" wrote:
| |
| | I'm not a .Net developer but I'd guess your code creates a text
file.
| Excel
| | 2007 is equally capable of opening a text file as Excel 2003 so that
| | shouldn't be a problem. Even if your code creates an Excel 2003
files
| | (.XLS) Excel 2007 can open that too.
| |
| | So I don't know what the problem is, but a clue would probably be
found
| in
| | the exact text of the error message which you should have included
in
| your
| | message.
| |
| | --
| | Jim
| | "Amitabh" wrote in message
| | ...
| | | Hi All,
| | | I have an web application where user can export the results of
search
| | action
| | | to an excel file so he can locally store it.. I have done this
with
| very
| | | simple code which is
| | | Response.ContentType = "application/vnd.ms-excel";
| | | Response.AppendHeader("content-disposition",
"attachment;
| | | filename=StackRanking.xls");
| | | Response.Charset = "";
| | | System.IO.StringWriter sw = new
System.IO.StringWriter();
| | | System.Web.UI.HtmlTextWriter hw = new
| | | System.Web.UI.HtmlTextWriter(sw);
| | | (........fils dataset..... hw.RenderBeginTag)
| | | (System.Web.UI.HtmlTextWriterTag.Html);
| | | dg.RenderControl(hw);
| | | hw.RenderEndTag();
| | | Response.Write(sw);
| | | Response.End();
| | |
| | | All work fine when end user has Excel 2003 but when he has Excel
2007
| it
| | | gives a warning err message when he tries to open the rendered
| | (downloaded)
| | | Excel File,
| | | I guess i need framework 3.0 to Support the file format of Excel
2007.
| | What
| | | in the code needs to be changed to have compatibility with Excel
2007
| | | File.....
| | |
| | | Thanks for reading my query...
| | | --
| | | Software Engineer
| | |
| |
| |
| |
|
|
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 XML Export biz7 Excel Worksheet Functions 0 July 10th 09 02:38 AM
export of data from SAP to MS-Excel 2007 Darshan Excel Discussion (Misc queries) 2 January 22nd 09 02:53 PM
Export Library from WMP 11 to Excel 2007 Dennis Excel Discussion (Misc queries) 0 February 3rd 08 08:18 PM
Excel 2007 export as XML size limit/bug Erik C. Nielsen Excel Discussion (Misc queries) 0 December 26th 07 07:09 PM
export data from sap to excel 2007 jain_sanju Excel Discussion (Misc queries) 0 December 17th 07 05:38 AM


All times are GMT +1. The time now is 03:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"