예제 #1
0
        public async Task <FileContentResult> Get(TaskState state)
        {
            var tasks = await taskFacade.GetTasks(state);

            var workBook = new XSSFWorkbook();
            var sheet    = workBook.CreateSheet();
            var rowIdx   = 0;
            var header   = sheet.CreateRow(rowIdx++);

            CreateTaskHeader(header, 0);

            foreach (var task in tasks)
            {
                WriteTask(sheet.CreateRow(rowIdx), task, 0, ref rowIdx);
                rowIdx++;
            }

            using var memoryStream = new MemoryStream();
            workBook.Write(memoryStream);
            return(File(memoryStream.ToArray(), "application/octet-stream", $"TaskReport_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"));
        }