コード例 #1
0
ファイル: HomeController.cs プロジェクト: hjdrent/MVCExcel
 public ActionResult Index()
 {
     AutoModel autoModel = new AutoModel()
     {
         AantalWielen = 4,
         Naam = "Bentley"
     };
     return View(autoModel);
 }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: hjdrent/MVCExcel
 public ActionResult Index(AutoModel model)
 {
     return View(model);
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: hjdrent/MVCExcel
 public ActionResult Contact(AutoModel model)
 {
     return View(model);
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: hjdrent/MVCExcel
 public ActionResult About(AutoModel model)
 {
     return View(model);
 }
コード例 #5
-1
ファイル: HomeController.cs プロジェクト: hjdrent/MVCExcel
        public ActionResult CreateStandardReport(AutoModel model)
        {
            string filename = "testje.xlsx";

            XLWorkbook workbook = new XLWorkbook();
            IXLWorksheet worksheet = workbook.Worksheets.Add("Scheet");

            worksheet.ActiveCell = worksheet.Cell(string.Format("A1"));
            worksheet.ActiveCell.Value = model.Naam;
            worksheet.ActiveCell = worksheet.Cell(string.Format("B1"));
            worksheet.ActiveCell.Value = model.AantalWielen;

            //worksheet.Columns().AdjustToContents();
            worksheet.ActiveCell = worksheet.Cell("A1");

            try
            {
                DownloadExcel(workbook, filename);
                model.Message = "Succes!";
                return View(model);
            }
            catch (Exception ex)
            {
                model.Message = ex.Message;
                return View("About", model);
            }
        }