code1 can execute successfully
code2 still has the following error message
<open "<0x100000043>|16|7">Script1.cs(16,7): error CS0260: Missing partial modifier on declaration of type 'Program'; another partial declaration of this type exists
<open "<0x100000043>|17|14">Script1.cs(17,14): warning CS7022: The entry point of the program is global code; ignoring 'Program.Main(string[])' entry point.
code1
code2
Linqpad has a big problem, it can't generate exe files, which happens to be the advantage of LA
But after the linqpad code is copied to the LA, there are still many modifications to be made, which is not very convenient
code2 still has the following error message
<open "<0x100000043>|16|7">Script1.cs(16,7): error CS0260: Missing partial modifier on declaration of type 'Program'; another partial declaration of this type exists
<open "<0x100000043>|17|14">Script1.cs(17,14): warning CS7022: The entry point of the program is global code; ignoring 'Program.Main(string[])' entry point.
code1
/*/ role exeProgram; outputPath %folders.Workspace%\exe\Script1; r %dll%\spire\Spire.Doc.dll; r %dll%\spire\Spire.PDF.dll; /*/
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
Environment.CurrentDirectory = @"C:\Users\Administrator\Desktop";
Document doc = new Document();
doc.LoadFromFile(@"Test2b.docx");
foreach (Section section in doc.Sections) {
foreach (Paragraph paragraph in section.Body.Paragraphs) {
if (paragraph.StyleName != "Heading1") {
HashSet<float> fontSize = new HashSet<float>();
HashSet<Color> fontColor = new HashSet<Color>();
foreach (DocumentObject paraChildObject in paragraph.ChildObjects) {
if (paraChildObject.DocumentObjectType == DocumentObjectType.TextRange) {
TextRange textRange = paraChildObject as TextRange;
Font font = textRange.CharacterFormat.Font;
fontSize.Add(font.Size);
Color color = textRange.CharacterFormat.TextColor;
fontColor.Add(color);
if (font.Name == "kaiti") {
textRange.CharacterFormat.Font = new Font("liti", font.Size);
}
}
}
if (fontSize.Count > 1) {
setA(paragraph);
}
}
}
}
doc.SaveToFile(@"result.docx", FileFormat.Docx);
}
public static void setA(Paragraph para) {
para.Format.BeforeSpacing = 8f;
para.Format.AfterSpacing = 16f;
para.Format.LineSpacing = 16f;
para.Format.LineSpacingRule = LineSpacingRule.Exactly;
foreach (DocumentObject paraChildObject in para.ChildObjects) {
if (paraChildObject.DocumentObjectType == DocumentObjectType.TextRange) {
TextRange textRange = paraChildObject as TextRange;
if (Regex.IsMatch(textRange.Text, "^([A-Za-z]){1}[^.]*.")) {
textRange.CharacterFormat.Font = new Font("Consolas", 14);
}
if (Regex.IsMatch(textRange.Text, "^[\u4e00-\u9fbb]+")) {
textRange.CharacterFormat.Font = new Font("宋体", 14);
}
}
}
}
}
code2
/*/ role exeProgram; outputPath %folders.Workspace%\exe\Script1; r %dll%\spire\Spire.Doc.dll; r %dll%\spire\Spire.PDF.dll;/*/
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
script.setup(trayIcon: true, sleepExit: true);
//..
class Program {
static void Main(string[] args) {
Environment.CurrentDirectory = @"C:\Users\Administrator\Desktop";
Document doc = new Document();
doc.LoadFromFile(@"Test2b.docx");
foreach (Section section in doc.Sections) {
foreach (Paragraph paragraph in section.Body.Paragraphs) {
if (paragraph.StyleName != "Heading1") {
HashSet<float> fontSize = new HashSet<float>();
HashSet<Color> fontColor = new HashSet<Color>();
foreach (DocumentObject paraChildObject in paragraph.ChildObjects) {
if (paraChildObject.DocumentObjectType == DocumentObjectType.TextRange) {
TextRange textRange = paraChildObject as TextRange;
Font font = textRange.CharacterFormat.Font;
fontSize.Add(font.Size);
Color color = textRange.CharacterFormat.TextColor;
fontColor.Add(color);
if (font.Name == "kaiti") {
textRange.CharacterFormat.Font = new Font("liti", font.Size);
}
}
}
if (fontSize.Count > 1) {
setA(paragraph);
}
}
}
}
doc.SaveToFile(@"result.docx", FileFormat.Docx);
}
public static void setA(Paragraph para) {
para.Format.BeforeSpacing = 8f;
para.Format.AfterSpacing = 16f;
para.Format.LineSpacing = 16f;
para.Format.LineSpacingRule = LineSpacingRule.Exactly;
foreach (DocumentObject paraChildObject in para.ChildObjects) {
if (paraChildObject.DocumentObjectType == DocumentObjectType.TextRange) {
TextRange textRange = paraChildObject as TextRange;
if (Regex.IsMatch(textRange.Text, "^([A-Za-z]){1}[^.]*.")) {
textRange.CharacterFormat.Font = new Font("Consolas", 14);
}
if (Regex.IsMatch(textRange.Text, "^[\u4e00-\u9fbb]+")) {
textRange.CharacterFormat.Font = new Font("宋体", 14);
}
}
}
}
}
Linqpad has a big problem, it can't generate exe files, which happens to be the advantage of LA
But after the linqpad code is copied to the LA, there are still many modifications to be made, which is not very convenient