10-28-2022, 01:53 PM
The following code, after generating the exe, fails to execute with a batch command
@echo off
Script6.exe "a" "C:\Users\Administrator\Desktop" "abc.docx"
pause
@echo off
Script6.exe "a" "C:\Users\Administrator\Desktop" "abc.docx"
pause
// script ""
/*/ role exeProgram; outputPath %folders.Workspace%\exe\Script6; r %dll%\spire\Spire.Doc.dll; r %dll%\spire\Spire.Pdf.dll; /*/
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
class Program {
public static void Main(string[] args) {
if (script.testing) {
args = new[] { @"queries\Spire\SP_多个位置加水印.linq", //代码路径
@"C:\Users\Administrator\Desktop", //args[1] 当前路径
@"日期域.docx", //args[2] 输出文件
};
}
Environment.CurrentDirectory = args[1];
Document document = new Document();
Section section = document.AddSection();
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("今天的日期为: ");
Field field = paragraph.AppendField("Date", FieldType.FieldData) as Field;
field.Code = @"DATE \@" + "\"yyyy年MM月dd日 \"";
document.SaveToFile(args[2], FileFormat.Docx2013);
}
}