 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris M Guest
|
Posted: Thu Jan 29, 2004 1:08 am Post subject: Word Table. |
|
|
I can _finally_ get a word table to appear in word where I want it to.
Now, what I need to do is to have the results of a tquery populate the
table.
Below is part of the code. What I want to do is to try to either a) set the
table to have automatically adustable widths for each column based on the
content (is that possible?) or b) set the width of the column based on the
displaywidth of the field. table.width is in points? displaywidth of tfield
is in what? which method is better and how can I accomplish this. Any code
examples are appreciated.
r.InsertParagraphAfter;
R.Collapse(Direction);
qryRooms.open;
MyTable := doc.Tables.Add(R, qryRooms.RecordCount,
qryRooms.Fields.Count,emptyparam,emptyparam);
MyTable.Borders.OutsideLineStyle := wdLineStyleNone;
MyTable.Borders.InsideLineStyle := wdLineStyleNone;
Mytable.Range.ParagraphFormat.Alignment := wdAlignParagraphCenter;
for x := 1 to qryRooms.fields.count do
begin
MyTable.Cell(1,x).range.text := qryRooms.Fields[x-1].DisplayLabel;
{The follow IF statement sets the display width wrong}
if qryRooms.Fields[x-1].displaywidth > 11 then
Mytable.Cell(1,x).Width := (qryRooms.Fields[x-1].displaywidth)
else
mytable.cell(1,x).width := 11;
end;
x := 2;
while not qryRooms.eof do
begin
MyTable.cell(x,1).range.text := qryRooms.Fields[0].asString;
MyTable.cell(x,2).range.text := formatdatetime('hh:mm
ampm',qryRooms.Fields[1].asDateTime);
MyTable.cell(x,3).range.text := formatdatetime('hh:mm
ampm',qryRooms.Fields[2].asDateTime);
MyTable.cell(x,4).range.text := qryRooms.Fields[3].asString;;
MyTable.cell(x,5).range.text := qryRooms.Fields[4].asString;;
inc(x);
qryRooms.next;
end;
qryRooms.close;
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Thu Jan 29, 2004 5:50 am Post subject: Re: Word Table. |
|
|
1. to autofit column widths:
table.Columns.AutoFit;
2. to set thw width for column
table.Columns.Item(i).SetWidth(<your width>, wdAdjustNone);
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Chris M" <chris (AT) eventsoft (DOT) com> wrote
| Quote: | I can _finally_ get a word table to appear in word where I want it to.
Now, what I need to do is to have the results of a tquery populate the
table.
Below is part of the code. What I want to do is to try to either a) set
the
table to have automatically adustable widths for each column based on the
content (is that possible?) or b) set the width of the column based on the
displaywidth of the field. table.width is in points? displaywidth of
tfield
is in what? which method is better and how can I accomplish this. Any
code
examples are appreciated.
r.InsertParagraphAfter;
R.Collapse(Direction);
qryRooms.open;
MyTable := doc.Tables.Add(R, qryRooms.RecordCount,
qryRooms.Fields.Count,emptyparam,emptyparam);
MyTable.Borders.OutsideLineStyle := wdLineStyleNone;
MyTable.Borders.InsideLineStyle := wdLineStyleNone;
Mytable.Range.ParagraphFormat.Alignment := wdAlignParagraphCenter;
for x := 1 to qryRooms.fields.count do
begin
MyTable.Cell(1,x).range.text :=
qryRooms.Fields[x-1].DisplayLabel;
{The follow IF statement sets the display width wrong}
if qryRooms.Fields[x-1].displaywidth > 11 then
Mytable.Cell(1,x).Width := (qryRooms.Fields[x-1].displaywidth)
else
mytable.cell(1,x).width := 11;
end;
x := 2;
while not qryRooms.eof do
begin
MyTable.cell(x,1).range.text := qryRooms.Fields[0].asString;
MyTable.cell(x,2).range.text := formatdatetime('hh:mm
ampm',qryRooms.Fields[1].asDateTime);
MyTable.cell(x,3).range.text := formatdatetime('hh:mm
ampm',qryRooms.Fields[2].asDateTime);
MyTable.cell(x,4).range.text := qryRooms.Fields[3].asString;;
MyTable.cell(x,5).range.text := qryRooms.Fields[4].asString;;
inc(x);
qryRooms.next;
end;
qryRooms.close;
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|