128
iRows:=StringGrid.RowCount;
CreateTable(iRows,iCols,Table);
for iGridRows := 1 to iRows do
for jGridCols := 1 to iCols do
W.ActiveDocument.Tables.Item(Table).Cell(iGridRows, jGridCols).Range.Text:=
StringGrid.Cells[jGridCols - 1, iGridRows - 1];
W.ActiveDocument.Range.InsertAfter(' ');
Table:=W.ActiveDocument.Tables.Count;
W.ActiveDocument.Tables.Item(Table).AutoFitBehavior(wdAutoFitContent);
InsertParagraphAfterTable(Table);
except
end;
end;
procedure GetStringGridInTable2(StringGrid:TStringGrid;var
Table:integer;ColArr:array of integer);
var
S:string;
icols,irows,iGridRows,jGridCols:integer;
begin
try
iCols:=Length(ColArr);
iRows:=StringGrid.RowCount;
CreateTable(iRows,iCols,Table);
for iGridRows := 1 to iRows do
for jGridCols := Low(ColArr) to High(ColArr) do
W.ActiveDocument.Tables.Item(Table).Cell(iGridRows, jGridCols+1).Range.Text:=
StringGrid.Cells[ColArr[jGridCols], iGridRows - 1];
W.ActiveDocument.Range.InsertAfter(' ');
Table:=W.ActiveDocument.Tables.Count;
W.ActiveDocument.Tables.Item(Table).AutoFitBehavior(wdAutoFitContent);
InsertParagraphAfterTable(Table);
except
end;
end;
procedure WordTableAddFromDBGrid(DBGrid: TDBGrid;CollSize:boolean;var
Table:integer);
var i, j,Col,Row,ColWidth: Integer;
S:string;
begin
Col:=DBGrid.Columns.Count;
Row:=DBGrid.DataSource.DataSet.RecordCount+1;
//SetTextToDoc(DBGrid.Columns.Items[0].Title.Caption,true);
CreateTable(Row,Col,Table);
if CollSize then ColWidth:=DBGrid.Columns.Items[0].Width;
//W.Selection.Tables.Item(Table).Columns.Item(1).SetWidth(ColumnWidth:=ColWidth,R
ulerStyle:=wdAdjustNone);
For j:=0 To Col-1 Do