asp.net 文件导出导入的问题....求回答
有案例最好导入execl文件
[解决办法]
http://www.baidu.com/s?ie=utf-8&bs=yiyanxiyin&f=8&rsv_bp=1&wd=asp.net+%E5%AF%BC%E5%85%A5excel&rsv_sug3=16&rsv_sug=0&rsv_sug1=10&rsv_sug4=1127&inputT=4711
[解决办法]
C#导入、导出Excel
http://blog.csdn.net/yfz19890410/article/details/9026971
http://blog.sina.com.cn/s/blog_690892850100jpxa.html
http://www.cnblogs.com/davehuang/archive/2010/07/06/1772226.html
[解决办法]
Excel有分类的,看你服务器安装的版本是多少
下边是代码是office2007版
SqlParameter[] parameters = {
new SqlParameter("@StoresId", SqlDbType.Int),
};
parameters[0].Value = admin.RoleID.Value;
DataSet ds = DbHelperSQL.RunProcedure("P_GetStoresNum", parameters, "ds");
//这个是导出的内容集合
DataTable dt = ds.Tables[0];
NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
NPOI.SS.UserModel.Sheet sheet = book.CreateSheet("门店库存信息");
NPOI.SS.UserModel.Row row = sheet.CreateRow(0);
//标题
string[] title = { "产品", "总个数(个)", "销售总数量(个)", "剩余总数量(个)", "配送到其他门店(个)", " 向其他门店索要(个)" };
for (int i = 0; i < title.Length; i++)
{
row.CreateCell(i).SetCellValue(title[i].ToString());
}
//内容
for (int i = 0; i < dt.Rows.Count; i++)
{
NPOI.SS.UserModel.Row row2 = sheet.CreateRow(i + 1);
row2.CreateCell(0).SetCellValue(dt.Rows[i][0] + " - " + dt.Rows[i][1]);
row2.CreateCell(1).SetCellValue(GetNum(dt.Rows[i][5], dt.Rows[i][6], dt.Rows[i][8]));
row2.CreateCell(2).SetCellValue(dt.Rows[i][4].ToString() == "" ? "0" : dt.Rows[i][4].ToString());
row2.CreateCell(3).SetCellValue(dt.Rows[i][3].ToString() == "" ? "0" : dt.Rows[i][3].ToString());
row2.CreateCell(4).SetCellValue(dt.Rows[i][7].ToString() == "" ? "0" : dt.Rows[i][7].ToString());
row2.CreateCell(5).SetCellValue(dt.Rows[i][8].ToString() == "" ? "0" : dt.Rows[i][8].ToString());
}
//写入到客户端
System.IO.MemoryStream ms = new System.IO.MemoryStream();
book.Write(ms);
HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=门店库存信息.xls"));
HttpContext.Current.Response.BinaryWrite(ms.ToArray());
book = null;
ms.Close();
ms.Dispose();