public async Task MultipleSheetGenerateTemplate_Test()
        {
            var importer = new ExcelImporter();
            var result   = await importer.GenerateTemplateBytes <ImportClassStudentDto>();

            var filePath = GetTestFilePath($"{nameof(MultipleSheetGenerateTemplate_Test)}.xlsx");

            DeleteFile(filePath);
            result.ShouldNotBeNull();
            result.Length.ShouldBeGreaterThan(0);
            result.ToExcelExportFileInfo(filePath);
            File.Exists(filePath).ShouldBeTrue();

            using (var pck = new ExcelPackage(new FileInfo(filePath)))
            {
                //检查转换结果
                pck.Workbook.Worksheets.Count.ShouldBe(2);
#if NET461
                pck.Workbook.Worksheets[1].Name.ShouldBe("1班导入数据");
                pck.Workbook.Worksheets[2].Name.ShouldBe("2班导入数据");
#else
                pck.Workbook.Worksheets[0].Name.ShouldBe("1班导入数据");
                pck.Workbook.Worksheets[1].Name.ShouldBe("2班导入数据");
#endif
            }
        }
Esempio n. 2
0
        public async Task <byte[]> GenerateTemplate()
        {
            IImporter Importer = new ExcelImporter();
            var       content  = await Importer.GenerateTemplateBytes <ArticleImportDto>();

            return(content);
        }
Esempio n. 3
0
        /// <summary>
        ///     生成模板
        /// </summary>
        /// <returns></returns>
        public async Task <byte[]> GenerateTemplateBytesAsync <T>() where T : class, new()
        {
            var result = await ExcelImporter.GenerateTemplateBytes <T>();

            return(result);
        }