public FileResult TicketReportExport(DateTime? startTime, DateTime? endTime, string siteId, TicketKhComplainDto ticketKhComplain,
string hidAllData, int pageSize1, int pageNo1, string sort1, SortType direction1)
{
if (!startTime.HasValue)
{
startTime = DateTime.Now.Date.AddDays(-7);
}
if (!endTime.HasValue)
{
endTime = DateTime.Now;
}
else
{
endTime = endTime.Value.AddDays(1);
}
var hs = new Hashtable();
//查询你需要导出的数据,将其返回存入list
var result = _customerComplain.TicketReport(startTime, endTime, ticketKhComplain, new PageCondition
{
PageIndex = pageNo1,
PageSize = pageSize1,
Direction = direction1,
Sort = sort1
}, hidAllData);
var ms = ReportExport(result.Items.ToList(), new ExportSetWook(WriteExcelCNTicketReport));
return File(ms, "application/ms-excel", Url.Encode("xxxxx.xls"));
}
private void WriteExcelCNTicketReport(IWorkbook workBook, List<TicketKhComplainDto> orderCounts, string name)
{
var sheet = workBook.CreateSheet(name);
//设置表头
var callRow = sheet.CreateRow(0);
callRow.CreateCell(0).SetCellValue("日期");
callRow.CreateCell(1).SetCellValue("总量");
callRow.CreateCell(2).SetCellValue("其中二次");
callRow.CreateCell(3).SetCellValue("xxxx");
callRow.CreateCell(4).SetCellValue("xxx");
callRow.CreateCell(4).SetCellValue("xxx");
for (int j = 0; j <= 3; j++)
{
sheet.SetColumnWidth(j, 15 * 256);
}
for (int i = 1; i <= orderCounts.Count; i++)
{
//将查询出来的值与excel中对于
IRow row = sheet.CreateRow(i);
row.CreateCell(0).SetCellValue(orderCounts[i - 1].Timedate);
row.CreateCell(1).SetCellValue((orderCounts[i - 1].Sum));
row.CreateCell(2).SetCellValue((orderCounts[i - 1].Second));
row.CreateCell(3).SetCellValue((orderCounts[i - 1].Finish));
row.CreateCell(4).SetCellValue((orderCounts[i - 1].FDEALING));
row.CreateCell(5).SetCellValue((orderCounts[i - 1].FEfinish));
}