68 lines
1.6 KiB
Plaintext
68 lines
1.6 KiB
Plaintext
Type TSDocxTables = Class(TSVbaBase)
|
|
Uses TSDocxEnumerations;
|
|
|
|
public
|
|
Function Init(docx);
|
|
Function Operator[](index);
|
|
|
|
private
|
|
docx_;
|
|
|
|
public
|
|
// Methods
|
|
Function Add(Range, NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior);
|
|
Function Item(Index);
|
|
|
|
// Properties
|
|
property Count read ReadCount;
|
|
property NestingLevel read ReadNestingLevel;
|
|
Function ReadNestingLevel();
|
|
Function ReadCount();
|
|
|
|
End;
|
|
|
|
// ============== 实现 ================= //
|
|
Function TSDocxTables.Init(docx);
|
|
Begin
|
|
docx_ := docx;
|
|
End;
|
|
|
|
Function Operator TSDocxTables.[](index);
|
|
Begin
|
|
table := docx_.GetTable(index - 1);
|
|
table_obj := new TSDocxTable(self.Application, self.Creator, self);
|
|
table_obj.Init(docx_, table);
|
|
return table_obj;
|
|
End;
|
|
|
|
// Methods
|
|
Function TSDocxTables.Add(Range, NumRows, NumColumns, DefaultTableBehavior, AutoFitBehavior);
|
|
Begin
|
|
table := Range.AddTable(NumRows, NumColumns);
|
|
table_obj := new TSDocxTable(self.Application, self.Creator, self);
|
|
table_obj.Init(docx_, table);
|
|
if ifnil(DefaultTableBehavior) then DefaultTableBehavior := TSDocxEnumerations.wdWord8TableBehavior();
|
|
if DefaultTableBehavior = TSDocxEnumerations.wdWord8TableBehavior() then
|
|
begin
|
|
root := table.Root();
|
|
tplpr := root.FirstChildElement("w:tblPr");
|
|
style := tplpr.FirstChildElement("w:tblStyle");
|
|
if style then tplpr.DeleteChild(style);
|
|
end
|
|
if ifnil(AutoFitBehavior) then AutoFitBehavior := TSDocxEnumerations.wdAutoFitContent();
|
|
table_obj.AutoFitBehavior(AutoFitBehavior);
|
|
return table_obj;
|
|
End;
|
|
|
|
Function TSDocxTables.Item(Index);
|
|
Begin
|
|
return self[Index];
|
|
End;
|
|
|
|
// Properties
|
|
Function TSDocxTables.ReadCount();
|
|
Begin
|
|
return docx_.TablesCount();
|
|
End;
|
|
|