public async Task CreateFromTemplateTest_从模板导出Word_导出成功人工校验导出效果() { string curDir = Environment.CurrentDirectory; string fileUrl = Path.Combine(curDir, DateTime.Now.ToString("yyyyMMddHHmmss") + ".docx"); string pic1 = Path.Combine(curDir, "Resources", "1.jpg"); string pic2 = Path.Combine(curDir, "Resources", "2.jpg"); string pic3 = Path.Combine(curDir, "Resources", "3.jpg"); string templateurl = Path.Combine(curDir, "Resources", "CarWordTemplate.docx"); WordCarTemplateDTO car = new WordCarTemplateDTO() { OwnerName = "龚英韬", CarType = "豪华型宾利", CarPictures = new List <Picture>() { new Picture() { PictureUrl = pic1 }, new Picture() { PictureUrl = pic2 } }, CarLicense = new Picture { PictureUrl = pic3 } }; var word = await _wordExportService.CreateFromTemplateAsync(templateurl, car); File.WriteAllBytes(fileUrl, word.WordBytes); }
public async Task CreateWordFromMasterTable_根据母版Table生成Word包括图片占位符_手动观察生成效果() { string curDir = Environment.CurrentDirectory; string fileUrl = Path.Combine(curDir, DateTime.Now.ToString("yyyyMMddHHmmss") + ".docx"); string pic1 = Path.Combine(curDir, "Resources", "1.jpg"); string pic2 = Path.Combine(curDir, "Resources", "2.jpg"); string pic3 = Path.Combine(curDir, "Resources", "3.jpg"); string templateurl = Path.Combine(curDir, "Resources", "CarWordTemplate.docx"); var car1 = new WordCarTemplateDTO() { OwnerName = "龚英韬", CarType = "豪华型宾利", CarPictures = new List <Picture>() { new Picture() { PictureUrl = pic1, }, new Picture() { PictureUrl = pic2 } }, CarLicense = new Picture { PictureUrl = pic3 } }; var car2 = new WordCarTemplateDTO() { OwnerName = "龚英韬", CarType = "豪华型宾利", CarPictures = new List <Picture>() { new Picture() { PictureUrl = pic1 }, new Picture() { PictureUrl = pic2 } }, CarLicense = new Picture { PictureUrl = pic3 } }; var datas = new List <WordCarTemplateDTO>() { car1, car2 }; var word = await _wordExportService.CreateFromMasterTableAsync(templateurl, datas); File.WriteAllBytes(fileUrl, word.WordBytes); }