08-07-2025, 02:02 PM
Thanks for your testing.
Since all of my runtime-compiled code is related to Spire.Doc.dll, I’d like to simplify the code as much as possible.
Is it possible to compile and execute successfully using only the code below? How can I achieve that?
I removed the `using` directives and DLL references. I want to make these functionalities available globally.
__________________________________________________________________________________
string code = """
string sDir = @"C:\Test\spire";
string sTxt = "hello world!";
string sName = "hello.docx";
newDoc(sDir, sTxt, sName);
void newDoc(string sDir, string sTxt, string sName)
{
Environment.CurrentDirectory = sDir;
var doc = new Document();
var section = doc.AddSection();
var paragraph = section.AddParagraph();
paragraph.AppendText(sTxt);
doc.SaveToFile(sName, FileFormat.Docx2016);
}
""";
var c = CsScript.Compile(code);
c.Run();
Since all of my runtime-compiled code is related to Spire.Doc.dll, I’d like to simplify the code as much as possible.
Is it possible to compile and execute successfully using only the code below? How can I achieve that?
I removed the `using` directives and DLL references. I want to make these functionalities available globally.
__________________________________________________________________________________
string code = """
string sDir = @"C:\Test\spire";
string sTxt = "hello world!";
string sName = "hello.docx";
newDoc(sDir, sTxt, sName);
void newDoc(string sDir, string sTxt, string sName)
{
Environment.CurrentDirectory = sDir;
var doc = new Document();
var section = doc.AddSection();
var paragraph = section.AddParagraph();
paragraph.AppendText(sTxt);
doc.SaveToFile(sName, FileFormat.Docx2016);
}
""";
var c = CsScript.Compile(code);
c.Run();
