Exemple #1
0
 public async Task ExportHtmlBytesByTemplate_Test()
 {
     var tplPath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "ExportTemplates", "tpl1.cshtml");
     var tpl = File.ReadAllText(tplPath);
     var exporter = new HtmlExporter();
     var filePath = Path.Combine(Directory.GetCurrentDirectory(), nameof(ExportHtmlBytesByTemplate_Test) + ".html");
     if (File.Exists(filePath)) File.Delete(filePath);
     //此处使用默认模板导出
     var result = await exporter.ExportListBytesByTemplate(
         GenFu.GenFu.ListOf<ExportTestData>(), tpl);
     result.ShouldNotBeNull();
     using (var file = File.OpenWrite(filePath))
     {
         file.Write(result, 0, result.Length);
     }
     File.Exists(filePath).ShouldBeTrue();
 }