|
@@ -0,0 +1,41 @@
|
|
|
|
+using DocumentFormat.OpenXml.Packaging;
|
|
|
|
+using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
+
|
|
|
|
+using Text = DocumentFormat.OpenXml.Drawing.Text;
|
|
|
|
+
|
|
|
|
+namespace UniformMaterialManagementSystem.Utils
|
|
|
|
+{
|
|
|
|
+ public static class LicenseUtil
|
|
|
|
+ {
|
|
|
|
+ public static void ExportLicensePdf(string path, List<string> licenses)
|
|
|
|
+ {
|
|
|
|
+ var templateFilePath = "Template\\军需物资质量检验出厂许可证.docx";
|
|
|
|
+
|
|
|
|
+ using var document = WordprocessingDocument.Open(templateFilePath, isEditable: true);
|
|
|
|
+ var body = document.MainDocumentPart?.Document.Body;
|
|
|
|
+
|
|
|
|
+ var table = body?.Descendants<Table>().LastOrDefault();
|
|
|
|
+ if (table == null) return;
|
|
|
|
+
|
|
|
|
+ // 获取第一行
|
|
|
|
+ var previousRow = table.Descendants<TableRow>().First();
|
|
|
|
+
|
|
|
|
+ // 插入行
|
|
|
|
+ foreach (var license in licenses)
|
|
|
|
+ {
|
|
|
|
+ var newRow = new TableRow();
|
|
|
|
+ var cell1 = new TableCell(new Paragraph(new Run(new Text(license))));
|
|
|
|
+ var cell2 = new TableCell(new Paragraph(new Run(new Text(license))));
|
|
|
|
+ var cell3 = new TableCell(new Paragraph(new Run(new Text(license))));
|
|
|
|
+ var cell4 = new TableCell(new Paragraph(new Run(new Text(license))));
|
|
|
|
+
|
|
|
|
+ newRow.Append(cell1, cell2, cell3, cell4);
|
|
|
|
+ table.InsertAfter(previousRow, newRow);
|
|
|
|
+
|
|
|
|
+ previousRow = newRow;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|