102 lines
5.8 KiB
Plaintext
102 lines
5.8 KiB
Plaintext
|
|
TestDocuments();
|
|
|
|
|
|
Function TestDocuments();
|
|
Begin
|
|
openpath := "D:/temp/vbatable.docx";
|
|
savepath := "D:/temp/vba.docx";
|
|
application := new TSDocxApplication();
|
|
|
|
application.Documents.Add;
|
|
Documents := application.Documents;
|
|
Documents.Open(FileName : openpath);
|
|
Documents.Save();
|
|
println("Documents.Count = {}", Documents.Count);
|
|
application.Documents("vbatable.docx").Activate;
|
|
println("ActiveDocument.Name = {}", application.ActiveDocument.Name);
|
|
println("ActiveDocument.Tables.Count = {}", application.ActiveDocument.Tables.Count);
|
|
|
|
TestTableCell(application);
|
|
|
|
Documents[2].SaveAs2(FileName : savepath);
|
|
println("savepath = {}", savepath);
|
|
return;
|
|
|
|
|
|
End;
|
|
|
|
Function TestTables(application);
|
|
Begin
|
|
ActiveDocument := application.ActiveDocument;
|
|
// ActiveDocument.Tables(1).ApplyStyleDirectFormatting('样式1');
|
|
End;
|
|
|
|
Function TestTableCell(application);
|
|
Begin
|
|
ActiveDocument := application.ActiveDocument;
|
|
// tables := application.ActiveDocument.Tables;
|
|
// tables[1].AutoFitBehavior(class(TSDocxEnumerations).wdAutoFitContent());
|
|
// tables[1].Cell(1, 1).Delete(class(TSDocxEnumerations).wdDeleteCellsEntireColumn());
|
|
// tables[1].Cell(1, 1).Delete(class(TSDocxEnumerations).wdDeleteCellsEntireRow());
|
|
// tables[1].Cell(3, 3).Delete(class(TSDocxEnumerations).wdDeleteCellsShiftLeft());
|
|
// tables[1].Cell(1, 2).Delete(class(TSDocxEnumerations).wdDeleteCellsShiftUp());
|
|
// tables[1].Cell(5, 3).Delete(class(TSDocxEnumerations).wdDeleteCellsShiftUp());
|
|
// tables2 := ActiveDocument.Tables(2);
|
|
// tables2.Cell(1, 1).Delete(class(TSDocxEnumerations).wdDeleteCellsEntireColumn());
|
|
// tables2.Cell(1, 1).Delete(class(TSDocxEnumerations).wdDeleteCellsEntireRow());
|
|
// tables2.Cell(3, 3).Delete(class(TSDocxEnumerations).wdDeleteCellsShiftLeft());
|
|
// tables2.Cell(1, 2).Delete(class(TSDocxEnumerations).wdDeleteCellsShiftUp());
|
|
// tables2.Cell(5, 3).Delete(class(TSDocxEnumerations).wdDeleteCellsShiftUp());
|
|
// ActiveDocument.Tables(1).Cell(Row: 2, Column: 2).Merge(MergeTo: tables[1].Cell(2, 4));
|
|
// ActiveDocument.Tables(2).Cell(2, 2).Merge(ActiveDocument.Tables(2).Cell(3, 4));
|
|
// ActiveDocument.Tables(2).Cell(2, 2).Width := 100;
|
|
// println("ActiveDocument.Tables(2).Cell(2, 2).Width = {}", ActiveDocument.Tables(2).Cell(2, 2).Width);
|
|
// ActiveDocument.Tables(2).Cell(2, 3).WordWrap := true;
|
|
// println("ActiveDocument.Tables(2).Cell(2, 3).WordWrap = {}", ActiveDocument.Tables(2).Cell(2, 3).WordWrap);
|
|
// ActiveDocument.Tables(2).Cell(1, 1).VerticalAlignment := class(TSDocxEnumerations).wdCellAlignVerticalBottom();
|
|
// ActiveDocument.Tables(2).Cell(1, 2).VerticalAlignment := class(TSDocxEnumerations).wdCellAlignVerticalCenter();
|
|
// ActiveDocument.Tables(2).Cell(2, 2).VerticalAlignment := class(TSDocxEnumerations).wdCellAlignVerticalTop();
|
|
// println("ActiveDocument.Tables(2).Cell(1, 1).VerticalAlignment = {}", ActiveDocument.Tables(2).Cell(1, 1).VerticalAlignment);
|
|
// println("ActiveDocument.Tables(2).Cell(1, 2).VerticalAlignment = {}", ActiveDocument.Tables(2).Cell(1, 2).VerticalAlignment);
|
|
// println("ActiveDocument.Tables(2).Cell(1, 3).VerticalAlignment = {}", ActiveDocument.Tables(2).Cell(1, 3).VerticalAlignment);
|
|
// println("ActiveDocument.Tables(2).Cell(2, 2).VerticalAlignment = {}", ActiveDocument.Tables(2).Cell(2, 2).VerticalAlignment);
|
|
// ActiveDocument.Tables(2).Cell(1, 1).TopPadding := 30;
|
|
// ActiveDocument.Tables(2).Cell(1, 1).LeftPadding := 25;
|
|
// ActiveDocument.Tables(2).Cell(1, 1).BottomPadding := 20;
|
|
// ActiveDocument.Tables(2).Cell(1, 1).RightPadding := 15;
|
|
// println("ActiveDocument.Tables(2).Cell(1, 1).TopPadding = {}", ActiveDocument.Tables(2).Cell(1, 1).TopPadding);
|
|
// println("ActiveDocument.Tables(2).Cell(1, 1).LeftPadding = {}", ActiveDocument.Tables(2).Cell(1, 1).LeftPadding);
|
|
// println("ActiveDocument.Tables(2).Cell(1, 1).BottomPadding = {}", ActiveDocument.Tables(2).Cell(1, 1).BottomPadding);
|
|
// println("ActiveDocument.Tables(2).Cell(1, 1).RightPadding = {}", ActiveDocument.Tables(2).Cell(1, 1).RightPadding);
|
|
// ActiveDocument.Tables(2).Cell(3, 3).Tables(1).AutoFitBehavior(class(TSDocxEnumerations).wdAutoFitContent());
|
|
// ActiveDocument.Tables(2).Cell(3, 3).Tables(1).Cell(1, 1).Delete(class(TSDocxEnumerations).wdDeleteCellsEntireColumn());
|
|
// ActiveDocument.Tables(1).Cell(1, 1).Shading.Texture := class(TSDocxEnumerations).wdTextureHorizontal();
|
|
ActiveDocument.Tables(3).Cell(2,1).PreferredWidthType := class(TSDocxEnumerations).wdPreferredWidthAuto;
|
|
ActiveDocument.Tables(3).Cell(2,2).PreferredWidth := 1000;
|
|
println("ActiveDocument.Tables(3).Cell(2,2).PreferredWidth = {}", ActiveDocument.Tables(3).Cell(2,2).PreferredWidth);
|
|
|
|
End;
|
|
|
|
Function TestTableRows();
|
|
Begin
|
|
// ActiveDocument.Tables(1).Rows.WrapAroundText := true;
|
|
// ActiveDocument.Tables(2).Rows.WrapAroundText := false;
|
|
// println("Tables(1).Rows.WrapAroundText = {}", ActiveDocument.Tables(1).Rows.WrapAroundText);
|
|
// println("Tables(2).Rows.WrapAroundText = {}", ActiveDocument.Tables(2).Rows.WrapAroundText);
|
|
// ActiveDocument.Tables(1).Rows.WrapAroundText := false;
|
|
// println("Tables(1).Rows.WrapAroundText = {}", ActiveDocument.Tables(1).Rows.WrapAroundText);
|
|
End;
|
|
|
|
Function TestTableBorders();
|
|
Begin
|
|
// ActiveDocument.Tables(1).Borders(class(TSDocxEnumerations).wdBorderDiagonalUp).LineStyle := class(TSDocxEnumerations).wdLineStyleSingle;
|
|
// ActiveDocument.Tables(1).Cell(1, 1).Borders(class(TSDocxEnumerations).wdBorderDiagonalDown).LineStyle := class(TSDocxEnumerations).wdLineStyleSingle;
|
|
// ActiveDocument.Tables(1).Columns(1).SetWidth(100, class(TSDocxEnumerations).wdAdjustSameWidth());
|
|
// ActiveDocument.Tables(3).Columns(2).PreferredWidthType := class(TSDocxEnumerations).wdPreferredWidthPercent;
|
|
// ActiveDocument.Tables(3).Columns(2).PreferredWidth := 50;
|
|
// println("ActiveDocument.Tables(3).Columns(2).PreferredWidth = {}", ActiveDocument.Tables(3).Columns(2).PreferredWidth);
|
|
End;
|
|
|
|
|