텍스트 데이터를 MVC3의 csv로 내 보내야합니다. 나는 다음을 수행하십시오MVC 3을 사용하여 텍스트 데이터를 CSV로 내보내려면 어떻게해야합니까?
보기 :
$(".export").click(function() {
$.get("@Url.Action("Export","Log")");
});
CONTROLLER :
이 내용을 반환하지만 다른 이름으로 저장 및 열기 옵션 있는 창을 팝업하지 않습니다public ActionResult Export()
{
var sb = new StringBuilder();
var list = this.systemLogRepository.GetFilterList(
null, this.ControllerContext.RequestContext.HttpContext.Request.QueryString, null);
foreach (var item in list)
{
sb.AppendFormat(
"{0},{1},{2},{3},{4}", item.Machine.Name, item.PackageID, item.ErrorDescription, item.OccurenceTime, Environment.NewLine);
}
return this.File(new UTF8Encoding().GetBytes(sb.ToString()), "text/csv", string.Format("Log-{0}.csv", DateTime.Now.ToString("g").Replace("/","-").Replace(":","_").Replace(" ", "-")));
}
? 감사합니다.
다른 브라우저에서 사용해 볼 수 있습니까? – gideon