Save Web Pages or Parts to Client-Side Files

Recend days, need to save pages' data to client-side files with special suffix defaultly. Such as ms/word or ms/excel.

I have used the Devexpress ASPxGridView control to present data. And the presenting table is custom designed by using "DataRow template" property.

Not familar with Devexprss's reporting-controls and the ASPxGridViewExporter can not epxort customing Table-template's data to a file together with it's style.

The "Data Exporter“ of ASPxGridView can only export data as row by row as tryed as I do so far.

Then, I search and try other solutions.

Following are the solutions I tryed.

No.1:Devexpress GridView DataExport.

Issue: can not keep the formate table styles fo datarow template.

No.2: ActivexObject

Issue: client user has to set the safe setting of browser

No.3:Using JSdocument.execCommand("SaveAs").

When it responses "HTML" to client, we can use the JS to make a "HTML" file with customed content-type, such as ms/word or ms/excel, and get the HTML Codes of the special part, which you want to save to the file,  from the page.

Issue: but IE has the special rules as for safty consideration, the target file's type or suffix can only be plain or HTML type file, absolutely excluded ms/word or ms/excel. This may makes uses to be confused.

No.4: Write Response file in server's coding.

In this solution, as the exporting part includes Devexpress or MS server side controls. So you must make "Page.EnableEventValidation" Property to be "false" or you overwriter theRegisterForEventValidation method.
It's theory is same as "No.3": customly to write the response "HTML" file, dicide the MEMT type and the content of the responsing page. Web Browser(IE) will prompt user to save the file with Popout Dialog automatically.


Notes/Referce:

1.Page.EnableEventValidation Property :

http://msdn.microsoft.com/en-us/library/system.web.ui.page.enableeventvalidation.aspx;

http://msdn.microsoft.com/en-us/library/aa479045.aspx;

2.Event Validation in ASP.NET:http://www.dotnetfunda.com/articles/article916-event-validation-in-aspnet.aspx;

3.enableEventValidation错误原因分析以及解决办法:http://www.poluoluo.com/jzxy/201008/91887.html;

4.js word:http://cruelchen.blog.163.com/blog/static/78691844201132611546419/;

5.Js保存html为Word文件:http://home.51.com/glfxml/diary/item/10049930.html;
6.js 打开word(Asp.net):http://wenwen.soso.com/z/q193224023.htm;

在线打开Word的方式有两种

1、服务器使用ActiveX,常见的是OWC,客户端可见,但是要求客户端必需安装Office,另外客户修改的内容不能保存到服务器,除非你自己写处理

2、客户端通过JS调用你说的对象,更无法保存到服务器

 

其实第一种办法有公司做这种东西,就是在线编辑控件,我记得03年的时候用过江西金格的效果还不错

后来的就不是很清楚了。在线编辑Office文档,需要保证数据的安全性、同步性,还有修改存档,自己写难度很大,推荐你去看看他们的产品吧,不过是要花钱的。

继续追问:

那如果我只要能够下载下来看就好了,不需要编辑后上传 ,我该怎么做呢?

我new的这个对象不能用的哦,总是报我上面说的那个错误吖。

您说的这个服务器使用ActiveX 具体怎么操作呢?

在网上搜罗都没有找到实例吖?您能够给我一个实例吗?857421200@qq.com这个是我邮箱,谢谢您!非常感谢!

补充回答:

在线WebOffice,你去 http://www.goldgrid.com/看看吧

他们网站有演示,不过是收费的

7. 通过js保存图片到本地:http://www.cnblogs.com/Renn/archive/2011/08/02/2125047.html;

8.javascript利用IE另存为功能导出内容:http://hi.baidu.com/zonk518/item/50a884cd6a123525e90f2e84;

9.js 控制IE 自动保存网页:http://blog.csdn.net/jazywoo123/article/details/7539714;

10.IE中js document.execCommand()的用法小记:http://blog.csdn.net/jazywoo123/article/details/7539709;

11.SaveAs Command:http://bytes.com/topic/javascript/answers/852244-saveas-command;

12.MSDN execCommand method:http://msdn.microsoft.com/en-us/library/ms536419%28v=vs.85%29.aspx;

13.How do you prompt "File Save as" ? without using "document.execCommand":http://www.webhostingtalk.com/archive/index.php/t-429789.html;

14.Content-Type一览:http://blog.csdn.net/fanweiwei/article/details/1787747;

15.Hypertext Transfer Protocol -- HTTP/1.1:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html;

16.

How to manage ASP.NET validation from Javascript with jQuery:http://codeclimber.net.nz/archive/2008/05/14/how-to-manage-asp.net-validation-from-javascript-with-jquery.aspx;

17.

Understanding Asp.Net Ajax Client Library:http://www.dotnetfunda.com/articles/article868-understanding-aspnet-ajax-client-library.aspx;

18.

ASP.NET Validation in Depth:http://msdn.microsoft.com/en-us/library/aa479045.aspx;

19.






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值