![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
I have a web form in which I have a datagrid, I need to export this data to a Microsoft Excel sheet.
I’m doing it thus: Response.Clear(); Response.Buffer= true; Response.ContentType = "application/vnd.ms-excel"; Response.Charset = ""; this.EnableViewState = false; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); DataGrid1.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End(); But I'd like to avoid system ask user if desires open or save this file, instead would open excel sheet as another window and when user saves the file it be saved as an excel file. Does somebody knows how achieve this? I'll appreciate it very much. A.L.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Not really sure what it is you are trying to do, you could always export to CSV first though, Excel is capable of reading CSV along with a million other spreadsheet applications.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
Generally as a security thing you will not be able to open a file or save a file to a users computer. Its a major security hole if you can...
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
Thanks you Berto.
What is happening is that when user select open file and modify some column of it and then save file, the only way that have to do it is closing application, then systenm ask him if desire to save modifications, if the answer is yes, then ask a name for file and ask type of file. I'd like to have ever a file name, I inserted a line in my code: Response.AddHeader("Content-Disposition", "inline;filename=Clientes.xls"); to assign a name for file but still is asking for a name when open, modify and then save file. Do you have a clue that help me? A.L.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Oct 2004
Posts: 37
Rep Power: 0
![]() |
Hello:
I have an answer to display Excel sheet in another form. I only put this code: <form id = “Form1” method = “post” runat = “server” target = “_blank”> Where target is that do the entire trick. In C# I include this line: Response.AddHeader("Content-Disposition", "inline;filename=Clientes.xls"); When user decides to save the file it is saved with Clientes.xls as name, obviously as Book of Microsoft Excel as type. But when user decides to open the file and modify some column and then save it, system opens a window “Save As” where ask for file name and save as type. Why is asking about it if I already gave this data? How can I do that system when file is opened, modified and saved it be saved as Clientes.xls? I’ll thank your help. A.L.
__________________
<span style='color:red'>El Hombre que tiene Amigos, debe mostrarse Amigo...</span> |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
if the file is being saved through the web browser to a users computer it has to d/l the file generally, (unless web standard files or you cache it or something) but whenever you want to explicitly save a file the user always has the open of saving a file as some random name, or opening the file or jus tsaving it as far as i can remember, and as far as i know you cant override this unless you go into internet explorere exploits.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|