var
WordApp,WordDoc,WordTable:OleVariant;
V:Variant;
i,j,Col,Row,data_count:integer;
begin try
WordApp := GetActiveOleObject('Word.Application');
except
//未运行则运行之
WordApp := CreateOleObject('Word.Application');
end;
WordApp.Visible:=True; //注意设置属性相当重要
WordDoc:=WordApp.Documents.Add; //设置为增加状态 //WordApp.Selection.Paragraphs.Alignment:=wdAlignParagraphCenter; //对其方式 WordApp.Selection.TypeText('在Word中自由自在绘报表(试验)'); //标题 WordApp.Selection.TypeParagraph;//换行
WordApp.Selection.TypeParagraph;//换行
Row:=4;
Col:=5;
try WordApp.Selection.Paragraphs.Alignment:=wdAlignParagraphLeft; WordTable:=WordDoc.Tables.Add(WordApp.Selection.Range,Row,Col);//制表
WordApp,WordDoc,WordTable:OleVariant;
V:Variant;
i,j,Col,Row,data_count:integer;
begin try
WordApp := GetActiveOleObject('Word.Application');
except
//未运行则运行之
WordApp := CreateOleObject('Word.Application');
end;
WordApp.Visible:=True; //注意设置属性相当重要
WordDoc:=WordApp.Documents.Add; //设置为增加状态 //WordApp.Selection.Paragraphs.Alignment:=wdAlignParagraphCenter; //对其方式 WordApp.Selection.TypeText('在Word中自由自在绘报表(试验)'); //标题 WordApp.Selection.TypeParagraph;//换行
WordApp.Selection.TypeParagraph;//换行
Row:=4;
Col:=5;
try WordApp.Selection.Paragraphs.Alignment:=wdAlignParagraphLeft; WordTable:=WordDoc.Tables.Add(WordApp.Selection.Range,Row,Col);//制表
var
BCValue1 :String;
NowCell :Cell;
NowTable :Table;
NowRow :Row;
NowColumn :Column;
AlignStyle : OLEVariant; //需改为函数参数
HPosition : OLEVariant; //需改为函数参数
W9Behavior : OLEVariant; //需改为函数参数
AutoFitBe : OLEVariant; //需改为函数参数
NumberRows : OLEVariant;MoveUnit : OLEVariant;
MoveType : OLEVariant;
MoveExte : OLEVariant;i : Integer; //循环的行
j : Integer; //循环的列
L : TStringList; //填写表内容
TotalColumn : Integer; //总行数
begin
MoveUnit :=4;
MoveType :=wdCharacter;
MoveExte :=wdExtend;
NowTable:=WordDOC.Tables.Item(1);
NowCell :=NowTable.Cell(3,2);
NowCell.Select;
NumberRows :=2;
AlignStyle :=wdRelativeHorizontalPositionPage;
HPosition :=wdTableLeft;
W9Behavior :=wdWord9TableBehavior;
AutoFitBe :=wdAutoFitFixed;
NowTable :=WordDOC.Tables.Add(WordApplication1.Selection.Range,1,7,W9BeHavior,AutoFitBe);
NowTable.Rows.VerticalPosition :=5;
NowTable.Borders.Item(wdBorderLeft).Color := wdColorRed;
NowTable.Borders.Item(wdBorderRight).Color := wdColorRed;
NowTable.Borders.Item(wdBorderTop).Color := wdColorRed;
NowTable.Borders.Item(wdBorderBottom).Color := wdColorRed;
NowTable.Borders.Item(wdBorderHorizontal).Color := wdColorRed;
NowTable.Borders.Item(wdBorderDiagonalDown).Color := wdColorRed;
NowTable.Borders.Item(wdBorderDiagonalUp).Color := wdColorRed;
NowTable.Borders.InsideColor := wdColorRed;
NowRow :=NowTable.Rows.Item(1);
NowRow.Select;
WordAPP.Selection.InsertRowsBelow(NumberRows); //---------------------------设置列宽----------------------------------------//
NowColumn :=NowTable.Columns.Item(1);
NowColumn.Width :=72;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=14; NowColumn :=NowTable.Columns.Item(2);
NowColumn.Width :=168;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphJustify;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=12; NowColumn :=NowTable.Columns.Item(3);
NowColumn.Width :=52;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=7.5; NowColumn :=NowTable.Columns.Item(4);
NowColumn.Width :=52;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=7.5; NowColumn :=NowTable.Columns.Item(5);
NowColumn.Width :=52;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=7.5; NowColumn :=NowTable.Columns.Item(6);
NowColumn.Width :=52;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=7.5; NowColumn :=NowTable.Columns.Item(7);
NowColumn.Width :=52;
NowColumn.Select;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Size :=7.5;
//----------------------------------------------------------------------------// //-------------------------------设置行宽------------------------------------//
NowRow :=NowTable.Rows.Item(1);
NowRow.Select;
NowRow.Height:=38;
WordAPP.Selection.Font.Size :=18;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Color :=ColorType; NowRow :=NowTable.Rows.Item(2);
NowRow.Select;
NowRow.Height:=38;
WordAPP.Selection.Font.Size :=18;
WordAPP.Selection.ParagraphFormat.Alignment :=wdAlignParagraphCenter;
WordAPP.Selection.Cells.VerticalAlignment :=wdCellAlignVerticalCenter;
WordAPP.Selection.Font.Color :=ColorType; NowRow :=NowTable.Rows.Item(3);
NowRow.Select;
NowRow.Height:=57;
WordAPP.Selection.Font.Color :=ColorType;
你说的那些早上就弄出来了,但是你的也很好
现在困惑我得主要是页面设置里的纵向横向设置问题,能帮帮我看看嘛?