宝臣 王 3 месяцев назад
Родитель
Сommit
7f6aa0b35a

BIN
UniformMaterialManagementSystem/Template/军需物资质量检验出厂许可证.docx


+ 1 - 1
UniformMaterialManagementSystem/UniformMaterialManagementSystem.csproj

@@ -46,7 +46,7 @@
 
 	<ItemGroup>
 		<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
-		<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.0" />
+		<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
 		<PackageReference Include="FreeSpire.Doc" Version="12.2.0" />
 		<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.20" />
 		<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.20" />

+ 41 - 0
UniformMaterialManagementSystem/Utils/LicenseUtil.cs

@@ -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;
+            }
+
+
+        }
+    }
+}