日期:2014-05-17 浏览次数:20439 次
public ActionResult ExportQualifiedExaminees(int serviceid, int funcid, string condition)
{
RegistrationBLL bll = new RegistrationBLL();
IList<QualifiedExamineeEn> list = bll.GetQualifiedExaminees(serviceid, condition);
if (list == null
------解决方案--------------------
list.Count == 0)
{
return Alert("没有准考证信息", "~/Views/ExamService/SaveSuccess.aspx", new { controller = "Registration", action = "GetExamineeByPage", serviceid = serviceid, funcid = funcid });
}
using (MemoryStream m = bll.ExportQualifiedExaminees(Server.MapPath("~/Resources/考生签到表导出模版.xls"), list1[0].fServiceName, list, Server.MapPath("~/Common/Images/toeic_log.PNG")))
{
ExcelExportHandler.ExportFile(m, "application/ms-excel", "UTF-8", "GB2312", "考生签到表.xls");
}
return new EmptyResult();
}
public class ExcelExportHandler
{
public static void ExportFile(string content, string contentType, string charSet, string encodingName, string outPutFileName)
{
byte[] htmlBy = System.Text.Encoding.GetEncoding("GB2312").GetBytes(content);
MemoryStream stream = new MemoryStream(htmlBy);
ExportFile(stream, contentType, charSet, encodingName, outPutFileName);
}
public static void ExportFile(MemoryStream stream, string contentType, string charSet, string encodingName, string outPutFileName)
{
&nb