Excel导入导出,生成和下载Excel报表、附件等操作--ASP.NET
public class OutExcel
{
public static void OutExcel_bb(DataTable dt, string thepath, string temppath, int TitleNum, string Title1)
{
//通过调用Excel的查询来实现数据的导出,按固定格式
//ds:执行的记录集;thepath:模板文件的路径;sql:执行的SQL语句;FileName:保存的文件名
//TitleNum:表头列的行数
Excel.Application excel;
Excel._Workbook xBk;
Excel._Worksheet xSt; //string Conn = "OLEDB;Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=xdtz;User ID=sa;Password=sa;Max Pool Size = 512";
string path = thepath;
excel = new Excel.Application();
excel.Visible = false;
excel.UserControl = true;
xBk = excel.Workbooks.Add(path);
xSt = (Excel._Worksheet)xBk.Worksheets.get_Item(); xSt.Cells[, ] = Title1;
int StartRow = TitleNum;
for (int i = ; i < dt.Rows.Count; i++)
{
for (int j = ; j < dt.Columns.Count; j++)
{
xSt.Cells[StartRow + i, j + ] = dt.Rows[i][j].ToString();
}
} xBk.SaveAs(temppath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
excel.Visible = false; System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
xSt = null;
xBk.Close(false, null, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
xBk = null; excel.Workbooks.Close();
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
excel = null;
System.GC.Collect();
} public static void OutExcel_bb(List<List<string>> lsts, string thepath, string temppath, string TitleName)
{
//通过调用Excel的查询来实现数据的导出,按固定格式
//ds:执行的记录集;thepath:模板文件的路径;sql:执行的SQL语句;FileName:保存的文件名
//TitleNum:表头列的行数
Excel.Application excel;
Excel._Workbook xBk;
Excel._Worksheet xSt; string path = thepath;
excel = new Excel.Application();
excel.Visible = true;
excel.UserControl = true;
xBk = excel.Workbooks.Add(path);
xSt = (Excel._Worksheet)xBk.Worksheets.get_Item(); xSt.Cells[, ] = TitleName;
int StartRow = ; for (int i = ; i < lsts.Count; i++)
{
List<string> lst = lsts[i];
int colspan = ;
for (int j = ; j < lst.Count; j++)
{
int ri = StartRow + i, ci = (j + ) + colspan;
if (lst[j].Contains("colspan"))
{
int cp = Convert.ToInt16(lst[j].Split(':')[]);
xSt.get_Range(xSt.Cells[ri, ci - ], xSt.Cells[ri, (ci - ) + (cp - )]).Merge(true);
colspan += cp - ;
}
else
{
xSt.Cells[ri, ci] = lst[j];
}
}
}
// xSt.get_Range(xSt.Cells[3, 1], xSt.Cells[3, 2]).Merge(true);
// xSt.get_Range(xSt.Cells[4, 1], xSt.Cells[4, 2]).Merge(true); xBk.SaveAs(temppath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
excel.Visible = true; System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
xSt = null;
xBk.Close(false, null, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
xBk = null; excel.Workbooks.Close();
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
excel = null;
System.GC.Collect(); }
public static void OutExecl_cc(string Str,string Title)
{
StringWriter sw = new StringWriter();
sw.WriteLine(Title);
sw.WriteLine(Str);
sw.Close(); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(Title, System.Text.Encoding.UTF8) + ".xls");//中文
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.Write(sw);
HttpContext.Current.Response.End();
}
}
例:
protected void btnsearch_Click(object sender, EventArgs e)
{
AspNetPager1.CurrentPageIndex = ;
DataLoad();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TiaoJian == "")
TiaoJian = " 1=1 ";// and state = 1 if (this.hiddept.Value != "")
TiaoJian += " and deptid in(select id from dbo.Department where parentdept=" + this.hiddept.Value + ")";
if (this.txtname.Value != "")
TiaoJian += " and username like '%" + this.txtname.Value + "%'";
if (this.drop1.SelectedValue != "")
TiaoJian += " and state = " + this.drop1.SelectedValue + ""; DataSet ds = new BLL.Users().GetHMC(TiaoJian);
string tick = DateTime.Now.ToString("yyyyMMddHHmmssff");
string thepath = "Upload/temp/hmcgs.xls";
string temppath = MapPath("Upload/temp/") + tick + ".xls";
OutExcel(ds, thepath, temppath,,"花名册");
System.GC.Collect();
GetExcelFile(temppath,"花名册");
}
public void OutExcel(DataSet ds, string thepath, string temppath, int TitleNum, string Title1)
{
//通过调用Excel的查询来实现数据的导出,按固定格式
//ds:执行的记录集;thepath:模板文件的路径;sql:执行的SQL语句;FileName:保存的文件名
//TitleNum:表头列的行数
Excel.Application excel;
Excel._Workbook xBk;
Excel._Worksheet xSt; //string Conn = "OLEDB;Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=xdtz;User ID=sa;Password=sa;Max Pool Size = 512";
string path = MapPath(thepath);
excel = new Excel.Application();
excel.Visible = false;
excel.UserControl = true;
xBk = excel.Workbooks.Add(path);
xSt = (Excel._Worksheet)xBk.Worksheets.get_Item(); //xSt.Cells[2, 1] = Title1;
int StartRow = TitleNum + ;
for (int i = ; i < ds.Tables[].Rows.Count; i++)
{
xSt.Cells[StartRow + i, ] = (i + );
for (int j = ; j < ds.Tables[].Columns.Count; j++)
{
xSt.Cells[StartRow + i, j + ] = ds.Tables[].Rows[i][j].ToString();
}
} xBk.SaveAs(temppath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
excel.Visible = false;
System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
xSt = null;
xBk.Close(false, null, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
xBk = null; excel.Workbooks.Close();
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
excel = null;
System.GC.Collect();
} private void GetExcelFile(string temppath, string FileName)
{
System.IO.FileInfo file = new System.IO.FileInfo(temppath);
if (file.Exists)
{
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名 Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(FileName + "(" + DateTime.Now.ToString("yyyyMMddHHmmss") + ").xls"));
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response.AddHeader("Content-Length", file.Length.ToString());
// 指定返回的是一个不能被客户端读取的流,必须被下载
Response.ContentType = "application/ms-excel";
// 把文件流发送到客户端
Response.WriteFile(file.FullName);
// 停止页面的执行
Response.End();
} }
———————————————————————————————————————————————————————————————————————————
公共类:
public class ToExcell
{
/// <summary>
/// 执行存储过程
/// </summary>
/// <param name="PropName">存储过程名</param>
/// <param name="_params">参数</param>
/// <returns></returns>
public DataSet GetDataSet(string PropName, SqlParameter[] _params,int Id)
{
return DBUtility.NewDbHelperSQL.RunProcedure(PropName, _params, "tb1", Id);
} #region 下载报表
/// <summary>
///
/// </summary>
/// <param name="ds">查询出的数据</param>
/// <param name="ExcelFileName">excel名称</param>
public void MyXlsToExcelByDataSet(DataSet ds, string ExcelFileName)
{
DataTable dt = ds.Tables[];
XlsDocument xlsDocument = new org.in2bits.MyXls.XlsDocument();
xlsDocument.FileName = HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(ExcelFileName)) + "_" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".xls";
Worksheet worksheet = xlsDocument.Workbook.Worksheets.Add("sheet1");//Excel工作表名称
Cells cells = worksheet.Cells;
int columns = dt.Columns.Count;
for (int i = ; i < columns; i++)//列名
{
cells.Add(, (i + ), dt.Columns[i].ColumnName.ToString().Trim());
}
for (int j = ; j < dt.Rows.Count; j++)
{
for (int k = ; k < columns; k++)
{
cells.Add(j + , (k + ), dt.Rows[j][k].ToString().Trim());
}
}
xlsDocument.Send();
}
#endregion #region 下载报表
/// <summary>
///
/// </summary>
/// <param name="ds">查询出的数据</param>
/// <param name="ExcelFileName">excel名称</param>
/// <param name="rowName">对应的列名</param>
public void MyXlsToExcelByDataSet(DataSet ds, string ExcelFileName, string[] rowName)
{
DataTable dt = ds.Tables[];
XlsDocument xlsDocument = new org.in2bits.MyXls.XlsDocument();
xlsDocument.FileName = HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(ExcelFileName)) + "_" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".xls";
Worksheet worksheet = xlsDocument.Workbook.Worksheets.Add("sheet1");//Excel工作表名称
Cells cells = worksheet.Cells;
int columns = dt.Columns.Count;
for (int i = ; i < columns; i++)//列名
{
cells.Add(, (i + ), rowName[i].Trim());
}
for (int j = ; j < dt.Rows.Count; j++)
{
for (int k = ; k < columns; k++)
{
cells.Add(j + , (k + ), dt.Rows[j][k].ToString().Trim());
}
}
xlsDocument.Send();
}
#endregion #region 附件下载
/// <summary>
/// 附件下载方法
/// </summary>
/// <param name="fileName">文件名</param>
/// <param name="path">文件路径</param>
public void DownLoadFile(string fileName, string path)
{
HttpContext.Current.Response.BufferOutput = false; HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + DisposeFileName(fileName)); //HttpContext.Current.Server.UrlEncode(fileName));//防止中文名出现乱码
HttpContext.Current.Response.ContentType = "application/octstream";
HttpContext.Current.Response.CacheControl = "Private";
Stream stream = new FileStream(HttpContext.Current.Server.MapPath(path), FileMode.Open, FileAccess.Read, FileShare.Read);
HttpContext.Current.Response.AppendHeader("Content-length", stream.Length.ToString()); BinaryReader br = new BinaryReader(stream); byte[] bytes; for (int n = ; n < (br.BaseStream.Length / + ); n++)
{
bytes = br.ReadBytes();
HttpContext.Current.Response.BinaryWrite(bytes);
System.Threading.Thread.Sleep(); //休息一下,防止耗用带宽太多。
} stream.Close();
}
#endregion
#region 文件下载时文件名处理
/// <summary>
/// 文件下载时文件名处理
/// </summary>
/// <param name="FileName"></param>
/// <returns></returns>
protected string DisposeFileName(string FileName)
{
FileName = FileName.Replace(" ", "");//去掉空格
return FileName;
} #endregion
}
.NET读取Excel文件内容--导入,简单示例:
<%-- 前台--%>
<div> <%-- 文件上传控件 用于将要读取的文件上传 并通过此控件获取文件的信息--%> <asp:FileUpload ID="fileSelect" runat="server" /> <%-- 点击此按钮执行读取方法--%> <asp:Button ID="btnRead" runat="server" Text="ReadStart" /> </div>
//声明变量(属性)
string currFilePath = string.Empty; //待读取文件的全路径 string currFileExtension = string.Empty; //文件的扩展名
//Page_Load事件 注册按钮单击事件
protected void Page_Load(object sender, EventArgs e) { this.btnRead.Click += new EventHandler(btnRead_Click); } //按钮单击事件 //里面的3个方法将在下面给出
protected void btnRead_Click(object sender, EventArgs e)
{
Upload(); //上传文件方法
if (this.currFileExtension == ".xlsx" || this.currFileExtension == ".xls")
{
DataTable dt = ReadExcelToTable(currFilePath); //读取Excel文件(.xls和.xlsx格式)
}
else if (this.currFileExtension == ".csv")
{
DataTable dt = ReadExcelWidthStream(currFilePath); //读取.csv格式文件
}
}
下面列出按钮单击事件中的3个方法
///<summary>
///上传文件到临时目录中
///</ummary>
private void Upload()
{
HttpPostedFile file = this.fileSelect.PostedFile;
string fileName = file.FileName;
string tempPath = System.IO.Path.GetTempPath(); //获取系统临时文件路径
fileName = System.IO.Path.GetFileName(fileName); //获取文件名(不带路径)
this.currFileExtension = System.IO.Path.GetExtension(fileName); //获取文件的扩展名
this.currFilePath = tempPath + fileName; //获取上传后的文件路径 记录到前面声明的全局变量
file.SaveAs(this.currFilePath); //上传
} ///<summary>
///读取xls\xlsx格式的Excel文件的方法
///</ummary>
///<param name="path">待读取Excel的全路径</param>
///<returns></returns>
private DataTable ReadExcelToTable(string path)
{
//连接字符串
string connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"; // Office 07及以上版本 不能出现多余的空格 而且分号注意
//string connstring = Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"; //Office 07以下版本 因为本人用Office2010 所以没有用到这个连接字符串 可根据自己的情况选择 或者程序判断要用哪一个连接字符串
using(OleDbConnection conn = new OleDbConnection(connstring))
{
conn.Open();
DataTable sheetsName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new object[]{null,null,null,"Table"}); //得到所有sheet的名字
string firstSheetName = sheetsName.Rows[][].ToString(); //得到第一个sheet的名字
string sql = string.Format("SELECT * FROM [{0}],firstSheetName); //查询字符串
OleDbDataAdapter ada =new OleDbDataAdapter(sql,connstring);
DataSet set = new DataSet();
ada.Fill(set);
return set.Tables[]; }
} ///<summary>
///读取csv格式的Excel文件的方法
///</ummary>
///<param name="path">待读取Excel的全路径</param>
///<returns></returns>
private DataTable ReadExcelWithStream(string path)
{
DataTable dt = new DataTable();
bool isDtHasColumn = false; //标记DataTable 是否已经生成了列
StreamReader reader = new StreamReader(path,System.Text.Encoding.Default); //数据流
while(!reader.EndOfStream)
{
string meaage = reader.ReadLine();
string[] splitResult = message.Split(new char[]{','},StringSplitOption.None); //读取一行 以逗号分隔 存入数组
DataRow row = dt.NewRow();
for(int i = ;i<splitResult.Length;i++)
{
if(!isDtHasColumn) //如果还没有生成列
{
dt.Columns.Add("column" + i,typeof(string));
}
row[i] = splitResult[i];
}
dt.Rows.Add(row); //添加行
isDtHasColumn = true; //读取第一行后 就标记已经存在列 再读取以后的行时,就不再生成列
}
return dt;
}
示例完整代码,上传EXCEL并导入
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.OleDb; public partial class Tools_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
//资料导入点击事件
protected void Button1_Click(object sender, EventArgs e)
{
string clientid = Session["fileName"].ToString();
string CustTypeMax ="";
string CustTypeMin = "";
string CustTypeSub = "";
string sbResult = ExeclData(clientid, CustTypeMax, CustTypeMin, CustTypeSub);
alert("导入成功!");
}
private void alert(string str)
{ Page.ClientScript.RegisterStartupScript(this.GetType(), " ", "<script>alert('" + HttpUtility.UrlDecode(str) + "')</script>");
} //上传文件
protected void Button2_Click(object sender, EventArgs e)
{
string strFileName = InputAffixFile.Value.Trim();//文件名
string strFileSize = (Convert.ToInt32(InputAffixFile.PostedFile.ContentLength.ToString()) / ).ToString();//文件大小
string strFileType = strFileName.Substring(strFileName.LastIndexOf(".") + ).ToLower();//文件类型
string fileName = "";
string FilePath = "";
if (strFileName != "")
{
if (strFileType == "jpg" || strFileType == "psd" || strFileType == "swf" || strFileType == "gif " || strFileType == "bmp " || strFileType == "png " || strFileType == "xls" || strFileType == "doc" || strFileType == "pdf" || strFileType == "rar" || strFileType == "zip" || strFileType == "txt" || strFileType == "chm" || strFileType == "rtf" || strFileType == "docx" || strFileType == "wps" || strFileType == "xlsx" || strFileType == "et" || strFileType == "ppt" || strFileType == "pptx" || strFileType == "dps")
{
fileName = DateTime.Now.ToString("yyyMMddHHmmss") + "." + strFileType; ;//文件重命名
Session["fileName"] = fileName;
FilePath = System.Web.HttpContext.Current.Server.MapPath("~") + "//Upload//file";
InputAffixFile.PostedFile.SaveAs(FilePath + "/" + fileName);
Response.Write("<Script Language=JavaScript>alert(\"上传文件成功!\")</Script>");
}
else
{
Response.Write("<Script Language=JavaScript>alert(\"上传文件失败!\")</Script>");
}
}
else
{
Response.Write("<Script Language=JavaScript>alert(\"请选择上传文件!\")</Script>");
}
}
//资料导入方法
public static string ExeclData(string clientid, string CustTypeMax, string CustTypeMin, string CustTypeSub)
{
{
//获取上传的菜单名称和路径
string tempMenPath = System.Web.HttpContext.Current.Server.MapPath("~") + "Upload\\file\\" + clientid;//
StringBuilder sbResult = new StringBuilder("");
string strconn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + tempMenPath + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\"";
//string strconn = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + tempMenPath + "; Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strconn);
conn.Open();
string sql;
sql = "SELECT * FROM [Sheet1$]";
DataSet objDS = new DataSet();
OleDbDataAdapter objadp = new OleDbDataAdapter(sql, conn);
objadp.Fill(objDS);
DataTable MenDt = objDS.Tables[];
conn.Close();
int result = ;
foreach (DataRow dr in MenDt.Select())
{
try
{
Cms.BLL.C_article bllarticle = new Cms.BLL.C_article();
Cms.Model.C_article modelarticle = new Cms.Model.C_article();
modelarticle.parentId = Convert.ToInt32(dr[].ToString());//栏目id
modelarticle.title = dr[].ToString();//标题
modelarticle.englishtitle = "";//英文标题
modelarticle.orderNumber = Convert.ToInt32(dr[].ToString());//排序 modelarticle.artFrom = "";
modelarticle.photoUrl = dr[].ToString();//缩略图
modelarticle.intro = dr[].ToString();//简介
modelarticle.content = dr[].ToString();//内容 modelarticle.seoTitle = dr[].ToString();//seo标题
modelarticle.seoKeyword = dr[].ToString();//seo关键词
modelarticle.seoDescription = dr[].ToString();//seo描述
modelarticle.isRecommend = Convert.ToInt32(dr[].ToString());//推荐
modelarticle.isChannel = "";//栏目推荐 modelarticle.isHidden = Convert.ToInt32(dr[].ToString());//是否隐藏
modelarticle.isCheck = Convert.ToInt32(dr[].ToString());//是否审核发布
modelarticle.isHot = Convert.ToInt32(dr[].ToString());//是否热门文章 modelarticle.isTop = Convert.ToInt32(dr[].ToString());//是否置顶
modelarticle.hits = Convert.ToInt32(dr[].ToString());//点击量
modelarticle.expClass = "";//
modelarticle.editTime = DateTime.Now;//最后编辑时间
modelarticle.updateTime = DateTime.Now;//添加时间 modelarticle.txtLinkUrl = "";//URL链接
modelarticle.txtsource = dr[].ToString();//信息来源
modelarticle.txtauthor = dr[].ToString();//文章作者 if (dr[].ToString() == "")
{ result = bllarticle.Add(modelarticle);
sbResult.Append("[" + dr[].ToString() + "]增加成功 <br />");
}
else
{
result = bllarticle.Add(modelarticle);
if (result > )
{
sbResult.Append("增加成功 <br />");
}
else
{
sbResult.Append("增加失败 <br />");
}
}
}
catch
{
continue;
}
} return sbResult.ToString();
//更新到数据库中
}
}
}
Excel导入导出,生成和下载Excel报表、附件等操作--ASP.NET的更多相关文章
- 基于EPPlus和NPOI实现的Excel导入导出
基于EPPlus和NPOI实现的Excel导入导出 CollapseNav.Net.Tool.Excel(NuGet地址) 太长不看 导入 excel 文件流将会转为 ExcelTestDto 类型的 ...
- Java Excel 导入导出(一)
本文主要描述通过java实现Excel导入导出 一.读写Excel三种常用方式 1.JXL——Java Excel开放源码项目:读取,创建,更新 2.POI——Apache POI ,提供API给Ja ...
- JAVA实现Excel导入/导出【转】
JAVA实现Excel导入/导出[转] POI的下载与安装 请到网站http://www.apache.org/dyn/closer.cgi/poi/右击超链接2.5.1.zip下载压缩包poi-bi ...
- Excel导入导出(篇二)
<body> <h3>一.Excel导入</h3> <h5>.模板下载:<a href="UpFiles/TemplateFiles/学 ...
- ASP.NET 之 常用类、方法的超级总结,并包含动态的EXCEL导入导出功能,奉上类库源码
实用类:UtilityClass 包含如下方法 判断对象是否为空或NULL,如果是空或NULL返回true,否则返回false 验证手机号是否正确 13,15,18 验证邮箱 验证网址 MD5加密,返 ...
- 一个基于POI的通用excel导入导出工具类的简单实现及使用方法
前言: 最近PM来了一个需求,简单来说就是在录入数据时一条一条插入到系统显得非常麻烦,让我实现一个直接通过excel导入的方法一次性录入所有数据.网上关于excel导入导出的例子很多,但大多相互借鉴. ...
- JeeSite中Excel导入导出
在各种管理系统中,数据的导入导出是经常用到的功能,通常导入导出以Excel.CSV格式居多.如果是学习的过程中,最好是自己实现数据导入与导出的功能,然而在项目中,还是调用现成的功能比较好.近期一直使用 ...
- java jxl excel 导入导出的 总结(建立超链接,以及目录sheet的索引)
最近项目要一个批量导出功能,而且要生成一个单独的sheet页,最后后面所有sheet的索引,并且可以点击进入连接.网上搜索了一下,找到一个方法,同时把相关的excel导入导出操作记录一下!以便以后使用 ...
- JAVA Excel导入导出
--------------------------------------------方式一(新)-------------------------------------------------- ...
- [.Net] Excel导入导出各种方式分析
1.引言 1.1解决哪些问题 现在很多公司用的导出基本上采用的通过gridView导出excel,此种导出存在以下几种问题 1.数据量大的时候有时导出有时会让浏览器卡死,因为导出的excel不是真 ...
随机推荐
- 4G时代的抢钱之道
最近最大的事件恐怕就是移动的4G上线了,50元600M起计价,上网速度最高理论到达100Mbps,相当于一秒下载10MB的数据,或者是一分钟下载一张VCD(600M)电影. 当然,对于这样的流量套餐, ...
- php并发请求
一般在php进行请求url的时候,直接用 fopen 函数就可以搞定了,比如像这样: $file=fopen("http://www.cnblogs.com","r&qu ...
- [Bug]当IDENTITY_INSERT设置为OFF时,不能为表“xx”中的标识列插入显示的值
写在前面 在设计数据库表时,将主键设置为了自增的.在使用linq to sql的时候,添加数据,出现此错误. 解决方案 找到linq to sql生成的**.dbml文件,在对应的表上面右键修改其属性 ...
- 每天一个linux命令(30):cal 命令
cal命令可以用来显示公历(阳历)日历.公历是现在国际通用的历法,又称格列历,通称阳历.“阳历”又名“太阳历”,系以地球绕行太阳一周为一年,为西方各国所通用,故又名“西历”. 1.命令格式: cal ...
- 使用Struts2和jQuery EasyUI实现简单CRUD系统(转载汇总)
使用Struts2和jQuery EasyUI实现简单CRUD系统(一)——从零开始,ajax与Servlet的交互 使用Struts2和jQuery EasyUI实现简单CRUD系统(二)——aja ...
- Java-ArrayList和Vector的区别
这两个类都实现了List接口(List接口继承了Collection接口),他们都是有序集合,即存储在这两个集合中的元素的位置都是有顺序的,相当于一种动态的数组,我们以后可以按位置索引号取出某个元素, ...
- C 文件读写1
打开文件 fopen( ) 函数来创建或者打开文件,这个调用会初始化一个FILE 类型的对象. 原型 FILE *fopen( const char * filename, const char * ...
- 模式匹配KMP算法
关于KMP算法的原理网上有很详细的解释,我试着总结理解一下: KMP算法是什么 以这张图片为例子 匹配到j=5时失效了,BF算法里我们会使i=1,j=0,再看s的第i位开始能不能匹配,而KMP算法接下 ...
- 如何使用lessc编译.less文件
LESS :一种动态样式语言. LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承, 运算, 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, Firefox) ...
- poj 1743 二分答案+后缀数组 求不重叠的最长重复子串
题意:给出一串序列,求最长的theme长度 (theme:完全重叠的子序列,如1 2 3和1 2 3 or 子序列中每个元素对应的差相等,如1 2 3和7 8 9) 要是没有差相等这个条件那就好办 ...