var
wordApp, WordDoc, WrdSelection, wrdtable: variant;
strAdd: string;
wdPar,wdRange:OleVariant;
iCol, iRow, I, J: Integer;
begin
try
wordApp := CreateOleObject(‘Word.Application‘);
except
Application.MessageBox(‘Word没有安装‘, ‘提示信息‘, MB_OK+MB_ICONASTERISK+MB_DEFBUTTON1+MB_APPLMODAL);
Exit;
end;
Self.Chart_Edit.CopyToClipboardBitmap;
wordApp.Visible := true;
wordDoc:=WordApp.Documents.Add();
wordDoc.select;
wrdSelection := WordApp.selection;
strAdd:=‘XXX分析报告‘;
//strAdd:= Format(strAdd, [FormatDateTime(‘YYYY‘, Date), WeekofYear(Date)]);
wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
// wrdSelection.Font.bold := true;
// wrdSelection.Font.Size := 15;
// wrdSelection.TypeText(strAdd);
// wordApp.selection.TypeParagraph;//换行
// wrdSelection.Font.bold := false;
// wrdSelection.Font.Size := 10;
// wrdSelection.Font.bold := false;
// wrdSelection.ParagraphFormat.Alignment:=wdAlignParagraphLeft;
// wrdSelection.TypeText(‘打印时间:‘ + FormatDateTime(‘yyyy年hh月dd日 hh时MM分ss秒‘, Now));
// strAdd := ‘进样时间:‘ + FormatDateTime(‘yyyy年hh月dd日 hh时MM分ss秒‘, Now) + ‘ , 操作人:unknown‘;
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := ‘质检(E)字第()号‘;
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := ‘进样单位: ‘ + ‘ 仪器型号:SC-1001-09A‘;
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := ‘取样日期:‘ + FormatDateTime(‘yyyy年hh月dd日 ‘, Now) + ‘ 取样日期:‘ + FormatDateTime(‘yyyy年hh月dd日 ‘, Now);
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := ‘样品批号: ‘ + ‘ 样品名称:固液‘ ;
// wrdSelection.TypeText(stradd);
// wordApp.selection.TypeParagraph;//换行
// strAdd := ‘样品罐号: ‘ ;
// wrdSelection.TypeText(stradd);
wordApp.selection.TypeParagraph;//换行
wordApp.selection.paste;
wordApp.selection.TypeParagraph;//换行
wordApp.selection.TypeParagraph;//换行
wordApp.selection.TypeParagraph;//换行
wdPar:=WordApp.ActiveDocument.Paragraphs.Add;
wdRange:=wdPar.Range;
wdRange := wordApp.ActiveDocument.Content;
wdRange.Collapse(wdCollapseEnd);
iRow := SGrid_PeakResult.RowCount;
iCol := SGrid_PeakResult.ColCount;
wrdtable := wordDoc.Tables.Add(wdRange,iRow, iCol);
for I := 0 to SGrid_PeakResult.RowCount -1 do
begin
for J := 0 to SGrid_PeakResult.ColCount -1 do
begin
wrdtable.Cell(I,J).Range.Text:= SGrid_PeakResult.Cells[J, I];
end;
end;
wrdtable.Borders.Item(wdBorderLeft).LineStyle:=wdLineStyleSingle;
wrdtable.Borders.Item(wdBorderRight).LineStyle:=wdLineStyleSingle;
wrdtable.Borders.Item(wdBorderTop).LineStyle:=wdLineStyleSingle;
wrdtable.Borders.Item(wdBorderBottom).LineStyle:=wdLineStyleSingle;
wrdtable.Borders.Item(wdBorderHorizontal).LineStyle:=wdLineStyleSingle;
wrdtable.Borders.Item(wdBorderVertical).LineStyle:=wdLineStyleSingle;
wrdtable.Borders.Item(wdBorderVertical).LineWidth:= wdLineWidth150pt; //
end;