View Full Version : ارسال داده ها به اکسل
  
sina_rzv2
یک شنبه 28 مهر 1392, 11:40 صبح
سلام
کسی مقاله آموزشی داره در رابطه با این که چطور میشه اطلاعات رو از یک صفحه که با mvc4 ساخته شده و اطلاعات رو از یک دیتابیس میگیره به اکسل ارسال کرد؟ و این که چطور میشه از stimulsoft reporter تو mvc4 استفاده کرد؟
اگر کسی مقاله ای تو این زمینه ها داره ممنون میشم بهم معرفی کنه
m-rezaee
دوشنبه 29 مهر 1392, 15:08 عصر
public ActionResult ExportData()
        {
            GridView gv = new GridView();
            gv.DataSource = db.Studentrecord.ToList();
            gv.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=Marklist.xls");
           //Response.AddHeader("<meta http-equiv=""Content-type"" content=""text/html; charset=utf-8"" />");
            Response.AddHeader("Content-type", "text/html; charset=utf-8");
            Response.ContentType = "application/ms-excel";
            Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gv.RenderControl(htw);
            Response.Output.Write("<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />");
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            return RedirectToAction("StudentDetails");
        }
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.