首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

从网页经过response导出报表到Excel2007可行性分析

2012-07-31 
从网页通过response导出报表到Excel2007可行性分析GridView导出报表到Excel2007解决方案:1.从客户端取消警

从网页通过response导出报表到Excel2007可行性分析

GridView导出报表到Excel2007

解决方案:

1.      从客户端取消警告:

1) Run -   regedit
2) Navigate path -HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\OFFICE\12.0\EXCEL\SECURITY
3) Rightclick --> new>DWORD>
4) add key ExtensionHardening
5) value = 0

            Reference:

http://support.microsoft.com/kb/948615

2.      修改代码:

Excel 2007 实质是基于XML的,因此,此办法行不通。除非使用XML的SDK进行二次开发。

Reference:

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

http://www.microsoft.com/downloads/details.aspx?familyid=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

http://excelpackage.codeplex.com/

3.      将数据放入Memory再存入excel

(其实就是将数据直接存入Excel2007,如报表系统中的方式)

ExcelFile ef=new ExcelFile();

ExcelWorksheet ws= ef.Worksheets.Add("DataSheet");

ws.InsertDataTable(people,"A1", true);

 

Response.ContentType = "application/vnd.openxmlformats";

Response.AddHeader("Content-Disposition","attachment;filename=" +System.Web.HttpUtility.UrlEncode(FileName,System.Text.Encoding.UTF8) + ".xlsx");

// With XLSX it is a bit morecomplicated as MS Packaging API can't write

// directly to Response.OutputStream.Therefore we use temporary MemoryStream.

MemoryStreamms = new MemoryStream();

ef.SaveXlsx(ms);

ms.WriteTo(Response.OutputStream);

REFERENCE:

http://www.gemboxsoftware.com/spreadsheet/features/samples/asp-net-webdemo

http://www.gemboxsoftware.com/spreadsheet/features/samples/asp-net-webdemo-cs

4.      解决方案参考:

http://forums.asp.net/t/1221467.aspx/5/10

热点排行