You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
using MESClassLibrary.BLL.Injection;
|
|
using NPOI.SS.UserModel;
|
|
using NPOI.XSSF.UserModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace MESWebSite.HttpHandlers
|
|
{
|
|
/// <summary>
|
|
/// RepairRecordHandler 的摘要说明
|
|
/// </summary>
|
|
public class RepairRecordHandler : IHttpHandler
|
|
{
|
|
|
|
HttpRequest Request = null;
|
|
HttpResponse Response = null;
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
Request = context.Request;
|
|
Response = context.Response;
|
|
|
|
string method = Request.Params["method"];
|
|
switch (method)
|
|
{
|
|
case "QueryExcel":
|
|
QueryExcel();
|
|
break;
|
|
default:
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void QueryExcel()
|
|
{
|
|
string StartTime = Request.Params["StartTime"];
|
|
string EndTime = Request.Params["EndTime"];
|
|
|
|
InjectionDownRecordBLL bll = new InjectionDownRecordBLL();
|
|
List<List<string>> list = bll.SearchRepairRecordForExcel(StartTime, EndTime);
|
|
|
|
XSSFWorkbook book = new XSSFWorkbook();
|
|
ISheet sheet = book.CreateSheet("Sheet1");
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
IRow row = sheet.CreateRow(i);
|
|
|
|
for (int k = 0; k < list[i].Count; k++)
|
|
{
|
|
row.CreateCell(k).SetCellValue(list[i][k].ToString());
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// 写入到客户端
|
|
MemoryStream ms = new MemoryStream();
|
|
book.Write(ms);
|
|
Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmssfff")));
|
|
Response.BinaryWrite(ms.ToArray());
|
|
book = null;
|
|
ms.Close();
|
|
ms.Dispose();
|
|
|
|
}
|
|
}
|
|
}
|