StringGrid中内容的打印?
var
i:integer;
f: TextFile;
line :string;
begin
AssignPRN(f);
Rewrite(f);
Printer.Canvas.Font.Name := '宋体';
Printer.Canvas.Font.Size := 10;
Printer.Canvas.Font.PixelsPerInch := GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
Printer.Canvas.Font.Pitch :=fpFixed ;
Printer.Canvas.Font.Charset :=GB2312_CHARSET;
我相知道我打印的东东为什么不对齐?format怎么用才对?
// SetTextAlign(Printer.Canvas.Handle,TA_RIGHT );
line :=format('%12s%16s%12s%8s%12s%12s',['商品编码','商品名称','单价','数量','折扣额','小计']);
writeln(f,line);
for i:=0 to sg.RowCount -2 do
begin
if(sg.cells[7,i] <> '') then{sg是一个StringGrid控件}
begin
line := format('%12s%16s%12s%8s%12s%12s',
[sg.cells[1,i],sg.cells[2,i],sg.cells[3,i],
sg.cells[4,i],sg.cells[6,i],sg.cells[7,i]]);
writeln(f,line);
end;
end;
System.CloseFile(f);
end;