开发者

Open File Dialog Asp.Net

I am creating an excel report in vb.net using the office interop. When the report is completed I am saving the excel file on the C drive. The users have asked to save file anywhere they want not just the c drive. Can someone give me some code to popup an opend file dialog in asp.net?

I want the dialog to popup in a saveAs in ASP.NET. I know how to do it 开发者_StackOverflow社区in win forms, but I am creating an excel report in asp.net and calling the worksheet objects SaveAs property that excepts a fileName. So right now I just hardcode a file name in there. The users want to choose a file location


I think what you want is actually rather simple.

You can't save a file to the user's computer due to security restrictions (would you want a website saving a file to your computer?)

What you need to do is:

  1. Complete report
  2. Save report file to location on server, IE (.../myWebsite/files/GUID/myReport.rpt)
  3. Display link on next screen pointing to the report file

Doing this the user can right-click and save the file to wherever they want on their computer.

You can clean up these files on whatever schedule you would like.


Assuming you are actually talking about a desktop, winforms app then you can use the built in FileSaveDialog.

Official documentation is here:

  • http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx

but there are tons of tutorials explaining it out there:

  • http://www.google.co.uk/search?q=vb.net+savefiledialog


You can server files with the Open / Save dialog by using Response.TransmitFile().

The user is then presented with a save as dialog where they can choose the filename and the location on their computer.

You normally do this inside a HttpHandler. A simple one is described here:

  • http://blogs.msdn.com/petel/archive/2005/12/01/499189.aspx
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜