資源簡(jiǎn)介
基于NPOI的xls幫助類
導(dǎo)入支持03,07
導(dǎo)出支持03,07

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Web;
using?System.Web.UI;
using?System.Web.UI.WebControls;
using?System.Data;
using?System.Linq;
public?partial?class?_Default?:?System.Web.UI.Page?
{
????protected?void?Page_Load(object?sender?EventArgs?e)
????{
????}
????protected?void?btn_read_03_click(object?o?EventArgs?e)
????{
????????var?dt?=?ExcelHelper.GetDataTable(Server.MapPath(“~/xls_tmp/2003.xls“));
????????g1.DataSource?=?dt;
????????g1.DataBind();
????}
????protected?void?btn_read_07_click(object?o?EventArgs?e)
????{
????????var?dt?=?ExcelHelper.GetDataTable(Server.MapPath(“~/xls_tmp/2007.xlsx“));
????????g1.DataSource?=?dt;
????????g1.DataBind();
????}
????protected?void?btn_import_03_click(object?o?EventArgs?e)
????{
????????var?name?=?DateTime.Now.ToString(“yyyyMMddhhmmss“)?+?new?Random(DateTime.Now.Second).Next(10000);
????????var?path?=?Server.MapPath(“~/xls_down/“?+?name?+?“.xls“);
????????var?dt?=?new?System.Data.DataTable();
????????var?Columns=Enumerable.Range(1?10).Select(d?=>?new?DataColumn(“a“+d.ToString()?typeof(string))).ToArray();
????????dt.Columns.AddRange(Columns);
????????for?(int?i?=?0;?i?33333;?i++)
????????{
????????????var?id?=?Guid.NewGuid().ToString();
????????????dt.Rows.Add(id?id?id?id?id?id?id?id?id?id);
????????}
????????ExcelHelper.x2003.TableToExcelForXLS(dt?path);
????????downloadfile(path);
????}
????protected?void?btn_import_07_click(object?o?EventArgs?e)
????{
????????var?name?=?DateTime.Now.ToString(“yyyyMMddhhmmss“)?+?new?Random(DateTime.Now.Second).Next(10000);
????????var?path?=?Server.MapPath(“~/xls_down/“?+?name?+?“.xlsx“);
????????var?dt?=?new?System.Data.DataTable();
????????var?Columns?=?Enumerable.Range(1?10).Select(d?=>?new?DataColumn(“a“?+?d.ToString()?typeof(string))).ToArray();
????????dt.Columns.AddRange(Columns);
????????for?(int?i?=?0;?i?33333;?i++)
????????{
????????????var?id?=?Guid.NewGuid().ToString();
????????????dt.Rows.Add(id?id?id?id?id?id?id?id?id?id);
????????}
????????ExcelHelper.x2007.TableToExcelForXLSX(dt?path);
????????downloadfile(path);
????}
????void?downloadfile(string?s_path)
????{
????????System.IO.FileInfo?file?=?new?System.IO.FileInfo(s_path);
????????HttpContext.Current.Response.ContentType?=?“application/ms-download“;
????????HttpContext.Current.Response.Clear();
????????HttpContext.Current.Response.AddHeader(“Content-Type“?“application/octet-stream“);
????????HttpContext.Current.Response.Charset?=?“utf-8“;
????????HttpContext.Current.Response.AddHeader(“Content-Disposition“?“attachment;filename=“?+?System.Web.HttpUtility.UrlEncode(file.Name?System.Text.Encoding.UTF8));
????????HttpContext.Current.Response.AddHeader(“Content-Length“?file.Length.ToString());
????????HttpContext.Current.Response.WriteFile(file.FullName);
????????HttpContext.Current.Response.Flush();
????????HttpContext.Current.Response.Clear();
????????HttpContext.Current.Respon
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????9663??2014-07-09?14:42??xls\App_Code\ExcelHelper.cs
?????文件?????200704??2014-05-07?16:26??xls\Bin\ICSharpCode.SharpZipLib.dll
?????文件????1599488??2014-05-07?16:26??xls\Bin\NPOI.dll
?????文件?????395776??2014-05-07?16:26??xls\Bin\NPOI.OOxm
?????文件?????431466??2014-05-07?16:26??xls\Bin\NPOI.OOxm
?????文件??????84480??2014-05-07?16:26??xls\Bin\NPOI.Openxm
?????文件?????153211??2014-05-07?16:26??xls\Bin\NPOI.Openxm
?????文件????1866240??2014-05-07?16:26??xls\Bin\NPOI.Openxm
?????文件????2133648??2014-05-07?16:26??xls\Bin\NPOI.xm
?????文件???????1080??2014-07-09?14:51??xls\Default.aspx
?????文件???????3022??2014-07-09?15:00??xls\Default.aspx.cs
?????文件???????1680??2014-07-09?14:32??xls\web.config
?????文件??????10240??2014-07-09?14:42??xls\xls_tmp\2003.xls
?????文件???????7997??2014-07-09?14:39??xls\xls_tmp\2007.xlsx
?????目錄??????????0??2014-07-09?14:31??xls\App_Code
?????目錄??????????0??2014-07-09?14:41??xls\Bin
?????目錄??????????0??2014-07-09?14:58??xls\xls_down
?????目錄??????????0??2014-07-09?14:42??xls\xls_tmp
?????目錄??????????0??2014-07-09?14:43??xls
-----------?---------??----------?-----??----
??????????????6898695????????????????????19
- 上一篇:基于CST2013的微帶貼片天線仿真
- 下一篇:CISCO路由器配置
評(píng)論
共有 條評(píng)論