using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
using Microsoft.Office.Interop;
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
// GET: Home
private IMS_AppEntities _context = new IMS_AppEntities();
public ActionResult Index()
{
return View();
}
public JsonResult Get_Users_List()
{
return Json(new { aaData = _context.GetUser() }, JsonRequestBehavior.AllowGet);
}
public JsonResult Get_Stone_List()
{
return Json(new { aaData = _context.MST_Stone.ToList() }, JsonRequestBehavior.AllowGet);
}
//public string Export_Excel_Data()
//{
// Microsoft.Office.Interop.Excel.Application();
// Exce wb = new ExcelWorkbook();
// wb.Worksheets.Add("TEST EXCEL" + DateTime.Now.ToString());
// ExcelPackage p = new ExcelPackage();
// ExcelWorksheet ws = wb.Worksheets[1];
// ws = (ExcelWorksheet)wb.Worksheets.get_Item(1);
// ws.Name = "TEST EXCEL"; //Setting Sheet's name
// ws.Cells.Style.Font.Size = 11; //Default font size for whole sheet
// ws.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet
// ws.Cells[1, 1].Value = "STONE NO";
// wb.("your-file-name.xls");
// return "";
//}
private void Download_File()
{
var path = Request.QueryString["filepath"];
var file = new FileInfo(path);
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + file.Name + "\"");
Response.AddHeader("Content-Length", file.Length.ToString());
Response.TransmitFile(file.FullName);
HttpContext.ApplicationInstance.CompleteRequest();
}
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
using Microsoft.Office.Interop;
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
// GET: Home
private IMS_AppEntities _context = new IMS_AppEntities();
public ActionResult Index()
{
return View();
}
public JsonResult Get_Users_List()
{
return Json(new { aaData = _context.GetUser() }, JsonRequestBehavior.AllowGet);
}
public JsonResult Get_Stone_List()
{
return Json(new { aaData = _context.MST_Stone.ToList() }, JsonRequestBehavior.AllowGet);
}
//public string Export_Excel_Data()
//{
// Microsoft.Office.Interop.Excel.Application();
// Exce wb = new ExcelWorkbook();
// wb.Worksheets.Add("TEST EXCEL" + DateTime.Now.ToString());
// ExcelPackage p = new ExcelPackage();
// ExcelWorksheet ws = wb.Worksheets[1];
// ws = (ExcelWorksheet)wb.Worksheets.get_Item(1);
// ws.Name = "TEST EXCEL"; //Setting Sheet's name
// ws.Cells.Style.Font.Size = 11; //Default font size for whole sheet
// ws.Cells.Style.Font.Name = "Calibri"; //Default Font name for whole sheet
// ws.Cells[1, 1].Value = "STONE NO";
// wb.("your-file-name.xls");
// return "";
//}
private void Download_File()
{
var path = Request.QueryString["filepath"];
var file = new FileInfo(path);
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + file.Name + "\"");
Response.AddHeader("Content-Length", file.Length.ToString());
Response.TransmitFile(file.FullName);
HttpContext.ApplicationInstance.CompleteRequest();
}
}
}
No comments:
Post a Comment