请问如何象WORD一样画表格和在表内填文字,并能保存和调用。(能否留个QQ交流一个)( ( 积分: 100 )

  • 主题发起人 主题发起人 llw1
  • 开始时间 开始时间
L

llw1

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何象WORD一样画表格和在表内填文字,并能保存和调用。(能否留个QQ交流一个)
这是我的程序:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
NewTable,myRange,Word,do
c:OleVariant;
//, Fields
i:integer;
Align,ShowFirst:olevariant;
begin
try
Word:=CreateOleObject('Word.Application');
except
application.MessageBox('Çë°²×°Microsoft Word 2000 »ò¸ü¸ß°æ±¾£¡','¾¯¸æ£¡',mb_ok+mb_iconwarning);
abort;
end;
Word.Visible:=True;
//´´½¨¿ÕÎĵµ£»
Word.Documents.Add();
//½«Ò³Ãæ¸ÄΪ¡°ºáÏò¡±£»
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.LineNumbering.Active:=False;
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.TopMargin := 2/0.035;
Word.ActiveDocument.PageSetup.BottomMargin := 2/0.035;
Word.ActiveDocument.PageSetup.LeftMargin := 2/0.035;
Word.ActiveDocument.PageSetup.RightMargin := 2/0.035;
Word.ActiveDocument.PageSetup.Gutter := 0;
Word.ActiveDocument.PageSetup.HeaderDistance := 1.2/0.035;
Word.ActiveDocument.PageSetup.FooterDistance := 1.5/0.035;
Word.ActiveDocument.PageSetup.PageWidth := 29.7/0.035;
Word.ActiveDocument.PageSetup.PageHeight := 21/0.035;
Word.ActiveDocument.PageSetup.FirstPageTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.OtherPagesTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.SectionStart := wdSectionNewPage;
Word.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter := False;
Word.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter := False;
Word.ActiveDocument.PageSetup.VerticalAlignment := wdAlignVerticalTop;
Word.ActiveDocument.PageSetup.SuppressEndnotes := False;
Word.ActiveDocument.PageSetup.MirrorMargins := False;
Word.ActiveDocument.PageSetup.TwoPagesOnOne := False;
Word.ActiveDocument.PageSetup.GutterPos := wdGutterPosLeft;
Word.ActiveDocument.PageSetup.LayoutMode := wdLayoutModeLineGrid;
do
c := Word.ActiveDocument;
//дÈëҳüҳ½Å
//дÈëҳüҳ½Å
If word.ActiveWindow.View.SplitSpecial <> wdPaneNone then
begin
word.ActiveWindow.Panes(2).Close;
end;
If (word.ActiveWindow.ActivePane.View.Type=wdNormalView)
Or (word.ActiveWindow.ActivePane.View.Type=wdOutlineView) then
begin
word.ActiveWindow.ActivePane.View.Type:=wdPrintView;
end;

word.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
Word.Selection.Font.NameFarEast:='&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold:=false;
Word.Selection.Font.Italic:=wdToggle;
Word.Selection.TypeText(Text:='<< &amp;Ccedil;&amp;iquest;&amp;Auml;&amp;Ocirc;&amp;sup1;¤&amp;sup3;&amp;Igrave;&amp;Ograve;&amp;micro;&amp;Icirc;&amp;ntilde;&amp;Ntilde;&amp;micro;&amp;Aacute;·&amp;Iuml;&amp;micro;&amp;Iacute;&amp;sup3;
>>');
word.Application.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;
Align:=wdAlignPageNumberCenter;
ShowFirst:=True;
Word.ActiveDocument.Sections.Item(1).Footers.Item(1).PageNumbers.Add(Align,ShowFirst);
Word.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;
//&amp;ETH;&amp;acute;&amp;Egrave;&amp;euml;±ê&amp;Igrave;&amp;acirc;&amp;pound;&amp;raquo;
Word.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
Word.Selection.Font.NameFarEast:='&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=22;
Word.Selection.Font.Bold := true;
Word.Selection.TypeText(Text:='&amp;Ntilde;&amp;micro;&amp;Aacute;·&amp;frac14;&amp;AElig;&amp;raquo;&amp;reg;');
Word.Selection.TypeParagraph;
Word.Selection.ParagraphFormat.Alignment:= wdAlignParagraphJustify;
Word.Selection.Font.NameFarEast:='&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold := false;
//Word.Selection.Font.Bold:=wdToggle;
Word.Selection.TypeParagraph;
//&amp;raquo;&amp;shy;&amp;sup3;&amp;ouml;&amp;iquest;&amp;Otilde;±í&amp;cedil;&amp;ntilde;&amp;pound;&amp;raquo;
Word.ActiveDocument.Tables.Add(Range:=Word.Selection.Range,
NumRows:=10, //ClientDataSet_tmp.RecordCount+1,
NumColumns:=10,
DefaultTableBehavior:=0,
AutoFitBehavior:=0);
//&amp;ordm;&amp;Iuml;&amp;sup2;&amp;cent;±í&amp;cedil;&amp;ntilde;
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(1,1,wdMove);
word.Selection.MoveRight(1,5,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(2,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
end;
 
请问如何象WORD一样画表格和在表内填文字,并能保存和调用。(能否留个QQ交流一个)
这是我的程序:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
NewTable,myRange,Word,do
c:OleVariant;
//, Fields
i:integer;
Align,ShowFirst:olevariant;
begin
try
Word:=CreateOleObject('Word.Application');
except
application.MessageBox('&amp;Ccedil;&amp;euml;°&amp;sup2;×°Microsoft Word 2000 &amp;raquo;ò&amp;cedil;ü&amp;cedil;&amp;szlig;°&amp;aelig;±&amp;frac34;&amp;pound;&amp;iexcl;','&amp;frac34;&amp;macr;&amp;cedil;&amp;aelig;&amp;pound;&amp;iexcl;',mb_ok+mb_iconwarning);
abort;
end;
Word.Visible:=True;
//&amp;acute;&amp;acute;&amp;frac12;¨&amp;iquest;&amp;Otilde;&amp;Icirc;&amp;Auml;&amp;micro;&amp;micro;&amp;pound;&amp;raquo;
Word.Documents.Add();
//&amp;frac12;&amp;laquo;&amp;Ograve;&amp;sup3;&amp;Atilde;&amp;aelig;&amp;cedil;&amp;Auml;&amp;Icirc;&amp;ordf;&amp;iexcl;°&amp;ordm;á&amp;Iuml;ò&amp;iexcl;±&amp;pound;&amp;raquo;
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.LineNumbering.Active:=False;
Word.ActiveDocument.PageSetup.Orientation := wdOrientLandscape;
Word.ActiveDocument.PageSetup.TopMargin := 2/0.035;
Word.ActiveDocument.PageSetup.BottomMargin := 2/0.035;
Word.ActiveDocument.PageSetup.LeftMargin := 2/0.035;
Word.ActiveDocument.PageSetup.RightMargin := 2/0.035;
Word.ActiveDocument.PageSetup.Gutter := 0;
Word.ActiveDocument.PageSetup.HeaderDistance := 1.2/0.035;
Word.ActiveDocument.PageSetup.FooterDistance := 1.5/0.035;
Word.ActiveDocument.PageSetup.PageWidth := 29.7/0.035;
Word.ActiveDocument.PageSetup.PageHeight := 21/0.035;
Word.ActiveDocument.PageSetup.FirstPageTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.OtherPagesTray := wdPrinterDefaultBin;
Word.ActiveDocument.PageSetup.SectionStart := wdSectionNewPage;
Word.ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter := False;
Word.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter := False;
Word.ActiveDocument.PageSetup.VerticalAlignment := wdAlignVerticalTop;
Word.ActiveDocument.PageSetup.SuppressEndnotes := False;
Word.ActiveDocument.PageSetup.MirrorMargins := False;
Word.ActiveDocument.PageSetup.TwoPagesOnOne := False;
Word.ActiveDocument.PageSetup.GutterPos := wdGutterPosLeft;
Word.ActiveDocument.PageSetup.LayoutMode := wdLayoutModeLineGrid;
do
c := Word.ActiveDocument;
//&amp;ETH;&amp;acute;&amp;Egrave;&amp;euml;&amp;Ograve;&amp;sup3;&amp;Atilde;&amp;frac14;&amp;Ograve;&amp;sup3;&amp;frac12;&amp;Aring;
//&amp;ETH;&amp;acute;&amp;Egrave;&amp;euml;&amp;Ograve;&amp;sup3;&amp;Atilde;&amp;frac14;&amp;Ograve;&amp;sup3;&amp;frac12;&amp;Aring;
If word.ActiveWindow.View.SplitSpecial <> wdPaneNone then
begin
word.ActiveWindow.Panes(2).Close;
end;
If (word.ActiveWindow.ActivePane.View.Type=wdNormalView)
Or (word.ActiveWindow.ActivePane.View.Type=wdOutlineView) then
begin
word.ActiveWindow.ActivePane.View.Type:=wdPrintView;
end;

word.ActiveWindow.ActivePane.View.SeekView := wdSeekCurrentPageHeader;
Word.Selection.Font.NameFarEast:='&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold:=false;
Word.Selection.Font.Italic:=wdToggle;
Word.Selection.TypeText(Text:='<< &amp;Ccedil;&amp;iquest;&amp;Auml;&amp;Ocirc;&amp;sup1;¤&amp;sup3;&amp;Igrave;&amp;Ograve;&amp;micro;&amp;Icirc;&amp;ntilde;&amp;Ntilde;&amp;micro;&amp;Aacute;·&amp;Iuml;&amp;micro;&amp;Iacute;&amp;sup3;
>>');
word.Application.Selection.ParagraphFormat.Alignment := wdAlignParagraphRight;
Align:=wdAlignPageNumberCenter;
ShowFirst:=True;
Word.ActiveDocument.Sections.Item(1).Footers.Item(1).PageNumbers.Add(Align,ShowFirst);
Word.ActiveWindow.ActivePane.View.SeekView := wdSeekMainDocument;
//&amp;ETH;&amp;acute;&amp;Egrave;&amp;euml;±ê&amp;Igrave;&amp;acirc;&amp;pound;&amp;raquo;
Word.Selection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
Word.Selection.Font.NameFarEast:='&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=22;
Word.Selection.Font.Bold := true;
Word.Selection.TypeText(Text:='&amp;Ntilde;&amp;micro;&amp;Aacute;·&amp;frac14;&amp;AElig;&amp;raquo;&amp;reg;');
Word.Selection.TypeParagraph;
Word.Selection.ParagraphFormat.Alignment:= wdAlignParagraphJustify;
Word.Selection.Font.NameFarEast:='&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;';
Word.Selection.Font.NameAscii:='Times New Roman';
Word.Selection.Font.NameOther:='Times New Roman';
Word.Selection.Font.Name:='Times New Roman';
Word.Selection.Font.Size:=9;
Word.Selection.Font.Bold := false;
//Word.Selection.Font.Bold:=wdToggle;
Word.Selection.TypeParagraph;
//&amp;raquo;&amp;shy;&amp;sup3;&amp;ouml;&amp;iquest;&amp;Otilde;±í&amp;cedil;&amp;ntilde;&amp;pound;&amp;raquo;
Word.ActiveDocument.Tables.Add(Range:=Word.Selection.Range,
NumRows:=10, //ClientDataSet_tmp.RecordCount+1,
NumColumns:=10,
DefaultTableBehavior:=0,
AutoFitBehavior:=0);
//&amp;ordm;&amp;Iuml;&amp;sup2;&amp;cent;±í&amp;cedil;&amp;ntilde;
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(1,1,wdMove);
word.Selection.MoveRight(1,5,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(2,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
word.Selection.MoveRight(3,1,wdMove);
word.Selection.MoveDown(wdLine,1,wdExtend);
word.Selection.Cells.Merge;
end;
 
表格是table对象,单元格是cell对象,你的代码看不出,中文怎么都就变成了乱码?不清楚你的需求。
 
看看我以前参与的问题吧,看能不能找到你要的:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3072537
 
没人回答,我自己搞定.
 
后退
顶部