range重新设计

This commit is contained in:
csh
2023-11-29 17:27:34 +08:00
parent 3781bc96e7
commit f0560b2330
28 changed files with 2829 additions and 383 deletions
+9 -5
View File
@@ -17,19 +17,25 @@ Begin
println("ActiveDocument.Name = {}", application.ActiveDocument.Name);
println("ActiveDocument.Tables.Count = {}", application.ActiveDocument.Tables.Count);
ActiveDocument := application.ActiveDocument;
ActiveDocument.Paragraphs.Add;
prange := ActiveDocument.Range(2, 4);
prange.Font.Size := 20;
prange.ParagraphFormat.Alignment := 1;
return;
// TestTableCell(application);
// TestTableColumns(application);
// TestTables(application);
// TestParagraphs(application);
// TestRange(application);
TestBorders(application);
// TestBorders(application);
// arr := application.ActiveDocument.Range(0, 10);
// println("arr = {}", arr);
Documents[2].SaveAs2(FileName : savepath);
println("savepath = {}", savepath);
return;
End;
@@ -54,8 +60,6 @@ Begin
crange.InsertAfter(Text: ".after");
crange.InsertBefore(Text: ".before");
return;
ActiveDocument.Range(2, 17).Font.Size := 20;
println("ActiveDocument.Range(2, 4).Font.Size = {}", ActiveDocument.Range(2, 4).Font.Size);
println("ActiveDocument.Range(2, 5).Font.Size = {}", ActiveDocument.Range(2, 5).Font.Size);
+24
View File
@@ -0,0 +1,24 @@
Uses TSDocxEnumerations;
Application := new TSDocxApplication();
openpath := "D://temp//default.docx";
savepath := "D://temp//docx_vba_help.docx";
document := Application.Documents.Open(FileName: openpath);
document.Activate;
println("Documents.Count = {}", Application.Documents.Count);
ActiveDocument := Application.ActiveDocument;
println("ActiveDocument.Name = {}", ActiveDocument.Name);
println("\n");
ActiveDocument.Paragraphs.Add;
para := ActiveDocument.Paragraphs.Last;
para.Range.Text := "TSVBA帮助文档";
println("para = {}", para);
// para.Range.Font.Size := 20;
para.Format.Alignment := TSDocxEnumerations.wdAlignParagraphCenter();
para.Format.Apply(); // 写属性后要apply
// ActiveDocument.SaveAs2(FileName : savepath);
// println("ActiveDocument.SaveAs2 = {}", savepath);
+4
View File
@@ -0,0 +1,4 @@
Uses SampleUnit;
InterfaceFunction();
return;
+1 -1
View File
@@ -2,7 +2,7 @@
// xlsx.NewFile();
// xlsx.OpenFile("", "D:\\temp\\vba_new.xlsx");
application := new Application();
application := new XlsxApplication();
application.Workbooks.Add;
Workbooks := application.Workbooks;
Workbooks.Open(FileName : "D:/temp/vba_new.xlsx");