yl
2023-09-07 d91966256d4b507b3f49d9f1b231b258e52a019b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using VueWebCoreApi.Tools;
 
namespace VueWebCoreApi.Controllers
{
    [ApiExplorerSettings(GroupName = "Excel导入")]
    [ApiController]
    [Route("api/[controller]")]
    //[ChannelActionFilter]
    public class ImportExcelController : Controller
    {
        //定义全局信息返回变量
        ToMessage mes = new ToMessage();
 
        #region[Excel导入模板列表]
        /// <summary>
        /// Excel导入模板列表
        /// </summary>
        /// <returns></returns>
        [Route(template: "ExcelModelData")]
        [HttpGet]
        public JsonResult ExcelModelData()
        {
            List<ScoreReport> list = ExcelList.ExcelData();
            mes.code = "200";
            mes.data = list;
            return Json(mes);
        }
        #endregion
 
        #region [Excel导入模板下载]
        /// <summary>
        /// Excel导入模板下载
        /// </summary>
        /// <param name="FileCode"></param>
        /// <returns></returns>
        [Route(template: "DownLoadExcel")]
        [HttpGet]
        public JsonResult DownLoadExcel(string FileCode = null)
        {
            List<ScoreReport> list = ExcelList.ExcelData();
            list = list.Where(s => s.FileCode == FileCode).ToList();
            var filename = list[0].FileName + ".xls";
            string fileip = AppSetting.GetAppSetting("FileIP");
            var msg = fileip + "/Excel/" + filename;
            mes.code = "200";
            mes.data = msg;
            return Json(mes);
        }
        #endregion
    }
}