哪位大哥帮忙解决这个问题!现在是打印到打印机,我想把打印的内容输出到文件,EXCEL或者文本文件!(200分)

  • 主题发起人 主题发起人 pentium_delphi
  • 开始时间 开始时间
P

pentium_delphi

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TPairsForm1.printbtnClick(Sender: TObject);
begin
if PrintDialog1.Execute then
begin
printer.begindoc;
print_init;
print_pairs;
printer.enddoc;
end;
end;

procedure print_pairs;
var
i,j: integer;
s: string;
pl,pr: double;
begin
do_line(0,0,'WWSoft '+vertext);
do_center(3,'G H Y P A P E R S I P C O R P O R A T I O N');
do_center(4,'W O R L D W I D E S C A L I N G M E T H O D O L O G Y');
do_center(5,'P A I R S R E P O R T');
do_line(0,7,'Filename: '+ panelfilename);
do_line(cpl-20,7,'Report date: '+datetostr(date));
do_bar(0,8);
do_line( 0,9, 'Description : '+panelbuff.desc);
do_line(cpl-20,9, 'Test Date : '+datetostr(panelbuff.date));
do_line(0,10, 'Requested by : '+panelbuff.req);
do_line(cpl-20,10,'Number of Samples : '+inttostr(panelbuff.samples));
do_bar(0,11);
do_line(0,12,'Sample Code');
do_line(15,12,'Description');
do_line(cpl-20,12,'Standard Value');
do_bar(0,13);
for i := 1 to panelbuff.samples do
begin
do_line(5,-1,getfield(panelbuff.codes,1,' '));
s := copy(getfield(panelbuff.codes,1,','),13,99);
do_line(15,lines-1,s);
s := getfield(panelbuff.codes,2,',');
if s = '0' then s := '**';
do_line(cpl-20+5,lines-1,s);
end;
do_bar(0,-1);
do_line(0,-1,'Percent');
do_line(8,lines-1,'Code');
for i := 1 to 9 do do_line((i*5)+10,lines-1,inttostr(10-i));
for i := 2 to 9 do do_line(55+(i-1)*5,lines-1,inttostr(i));
do_line(100,lines-1,'Code');
do_line(108,lines-1,'Percent');
do_bar(0,-1);
for i := 1 to panelbuff.paircount do
begin
do_line(10,-1,copy(panelbuff.pairs,1,1));
calc_pairs(i);
pl := 0;
pr := 0;
for j := 1 to 17 do
begin
do_line((j*5)+10,lines-1,inttostr(pairs[j]));
if (j >= 1) and (j <= 8) then pl := pl + pairs[j];
if (j >= 10) and (j <= 17) then pr := pr + pairs[j];
end;
do_line(102,lines-1,copy(panelbuff.pairs,2,1));
do_line(2,lines-1,format('%3d',[round((pl/(pl+pr))*100)]));
do_line(110,lines-1,format('%3d',[round((pr/(pl+pr))*100)]));
end;
do_bar(0,-1);
do_line(0,-1,'Total number of panelists: '+inttostr(panelbuff.panelistcount));
do_bar(0,-1);
end;
----------------------------------------------
我想做的是当我点击printbtnClick(Sender: TObject)时如果没有任何打印机可以自动
 
是不是如果有打印机你使用直接打印,如果没有打印机得话导出EXCEL啊。

EXCEL/WORD打印使用SERVER直接写了。参考VBA帮助就可以,要么录制宏。

检测打印机啊:
参考
procedure TForm1.ButtonClick(Sender: Tobject);
begin
ComboBox1.Clear;
ComboBox1.Items.Assign(Printer.Printers);
if ComboBox1.Items.CommaText='' then
Messagedlg('你需要安装打印机才能打印!',mtError,[mbOk],0);
else
Form1.Print;
end;
 
后退
顶部