我用EXCEL做出来了一点。反正是满足了我自己的要求了。
procedure TFrmMain.CET6Click(Sender: TObject);
var
ExcelApp: Variant;
selection:variant;
aSheet: variant;
i:integer;
zkzno:string;
picstr:string;
fpath,fpath1:string;
errcount:integer;
xuehao:string;
begin
ExcelApp := CreateOleObject('Excel.Application' );
ExcelApp.Visible := True;
ExcelApp.Caption := 'Microsoft Excel--打印';
fpath:=extractfiledir(application.ExeName);
ExcelApp.WorkBooks.Add(fpath+'/demo.xls');
excelapp.activesheet.columns[3].columnwidth:=0.5; //设置间隔
i:=0;
errcount:=0;
fpath:=fpath+'/StuPic/';
adoquerycet6.First;
while not adoquerycet6.Eof do begin
//***************************************************************//
excelapp.worksheets[1].range['A'+inttostr(2+i),'A'+inttostr(2+i)].select;
asheet:=excelapp.activesheet;
//提取照片,如果为空的话,则采用jm.jpg。
xuehao:=adoquerycet6.fieldbyname('xuehao').asstring;
picstr:=fpath+xuehao+'.jpg';
if copy(picstr,length(picstr)-4,5)='/.jpg' then begin
picstr:=fpath+'jm.jpg';
errcount:=errcount+1;
end;
selection:=asheet.pictures.insert(picstr).select;
//照片缩放30%
excelapp.selection.ShapeRange.Height:= 89.25;
excelapp.Selection.ShapeRange.Width := 67.5;
Excelapp.worksheets[1].range['A'+inttostr(1+i),'B'+inttostr(1+i)].merge(emptyparam);
excelapp.worksheets[1].Range['A'+inttostr(1+i),'B'+inttostr(1+i)].HorizontalAlignment:=xlcenter;
Excelapp.worksheets[1].range['A'+inttostr(8+i),'B'+inttostr(8+i)].merge(emptyparam);
Excelapp.worksheets[1].range['A'+inttostr(2+i),'A'+inttostr(7+i)].merge(emptyparam);
Excelapp.worksheets[1].Range['A'+inttostr(2+i),'A'+inttostr(2+i)].ColumnWidth:=10.75;
Excelapp.worksheets[1].Range['B'+inttostr(2+i),'B'+inttostr(2+i)].ColumnWidth:=28.63;
ExcelApp.Cells[1+i,1].Value := '大学英语四级考试CET-4';
ExcelApp.Cells[2+i,2].Value := '学校:东华理工学院';
ExcelApp.Cells[3+i,2].Value := '院系:'+adoquerycet6.fieldbyname('xi').asstring;
zkzno:=adoquerycet6.fieldbyname('zhunkaozheng').asstring;
ExcelApp.Cells[4+i,2].Value := '考试地点:210教室第'+copy(zkzno,length(zkzno)-4+1,2)+'考场';
ExcelApp.Cells[5+i,2].Value := '准考证号:'+adoquerycet6.fieldbyname('zhunkaozheng').asstring;
ExcelApp.Cells[6+i,2].Value := '考生姓名:'+adoquerycet6.fieldbyname('xingming').asstring;
ExcelApp.Cells[7+i,2].Value := '考试时间:6月24日8:45-11:00';
ExcelApp.ActiveSheet.Rows[8+i].RowHeight := 0.65/0.035; // 1厘米
adoquerycet6.Next;
//***************************************************************//
i:=i+9; //本来为8,但空一行比较好.
adoquerycet6.Next;
end;
if errcount>0 then
showmessage('可能没有照片的有'+inttostr(errcount)+'个学生');
end;