procedure TFmPrtSlMx.SumGridMx;var
i,j:integer;
s:integer;
begin
for i:=1 to StringGrid1.Colcount-2 do
begin
s:=0;
for j:=1 to StringGrid1.RowCount-2 do
begin
try
s:=s+strtoint(StringGrid1.Cells[i,j]);
except
;
end;
end;
StringGrid1.Cells[i,StringGrid1.RowCount-1]:=inttostr(s);
end;
for j:=1 to StringGrid1.rowcount-1 do
begin
s:=0;
for i:=1 to StringGrid1.colCount-2 do
begin
try
s:=s+strtoint(StringGrid1.Cells[i,j]);
except
;
end;
end;
StringGrid1.Cells[StringGrid1.colCount-1,j]:=inttostr(s);
end;
end;
本文介绍了一个用于表格数据处理的程序,该程序可以自动计算每一行及每一列的数据总和,并将结果显示在指定位置。通过对表格中每个单元格的数据进行遍历和累加,实现了对字符串类型数字的有效转换及异常处理。

2788

被折叠的 条评论
为什么被折叠?



