Delphi:将列从一个excel表复制到另一个

时间:2012-05-11 08:20:14

标签: delphi excel com

我需要找到第一个单元格具有指定值的列(在每个工作表上不包括ProfitSheet)(它始终存在且每个工作表只有一个),然后将列复制到另一个工作表。就像那样:

for i := 2 to MsExcel.Sheets.Count do // sheets loop. Sheets[1] —  ProfitSheet
begin
  MsExcel.Sheets[i].Select;
  for j := 1 to 15 do // columns loop to find "Profit column"
    if MsExcel.Cells[1, j].Text = 'Profit' then
      // copy j column, usually I use something like 
      // VariantArr := MsExcel.Range[MsExcel.Cells[1, j], MsExcel.Cells[299, j]].Value
      // and then 
      // Range := MsExcel.Range[MsExcel.Cells[1,i], MsExcel.Cells[299, i]];
      // Range.Value := VariantArr;
      // but I don't know how to find last column's cell (where 299)
  MsExcel.Sheets['ProfitSheet'].Select;
  // copy col to the i column of ProfitSheet
end;

0 个答案:

没有答案
相关问题