给公司写的一个所得税计算软件需要将EXCEL表格里的数据导入到ACCESS里,并将打开的EXCEL表格数据显示到DBGRID里面
  上边dbgrid1是打开的EXCEL表格数据,下边dbgrid2是经过计算后的表格数据,下面的dbgrid2中的税款金额需要进行计算
  
  工资金额在数据库中的字段为gzje,税款金额在数据库中的字段为skje,国籍在数据库中的字段为gj
  
  先进行国籍的判断, 
  var temp,tempe:float;
  
  begin
  if gj='10' then
  temp=(gzje-800);//  temp=(工资金额-800),temp为一临时变量,计算得出的数据要求保留两位小数,即精确到分
  if temp<=500 then skje=temp*5%
  if temp>500 and temp <=2000 then skje=temp*10%-25
  if temp>2000 and temp <=5000 then skje=temp*15%-125
  ...
  else
  gj<>'10'  then   //如果国籍不为10,则
  tempe=(gzje-4000);
  if temp<=500 then skje=temp*5%
  if temp>500 and temp <=2000 then skje=temp*10%-25
  if temp>2000 and temp <=5000 then skje=temp*15%-125
  ... 
  
  end;
请问能给出全部的代码吗,我的D水平实在有够差的,现在急着要,肯请大家帮助我,谢谢大家了~!!!
http://bbs.2ccc.com/attachments/2005/ninipig_2005122113511.gif

解决方案 »

  1.   

    找很久了,就是没有找到啊可以不必用DBGRID来显示的
    只要能显示出EXCEL表格里和数据库里有数据就行了还有就是这里:
    adoquery1.close;
    adoquery1.sql.clear;
    adoquery1.sql.add('这里面不知道怎么加判断语句');
    adoquery1.execsql;
      

  2.   

    我倒,难道这个问题真的这么高难么?
    三个步骤而已,最主要是程序要得很急啊
    还是高人觉得太简单了而不懈一顾啊,帮帮菜鸟,也能胜造七级浮屠哈
    导入EXCEL》计算相关数据列》保存到数据库中。。
      

  3.   

    procedure TFrmImportExcel.FlatButton5Click(Sender: TObject);
    var
      i,j: integer;
      XLApp,sheet:Variant;
      F: File;
      AllFileName ,FilePath ,FileName ,FileExt :string;
      FullNamestr ,SurNameStr,GivenNameStr,DateOfBidhStr,NationalityStr :string;
    begin
      AllFileName :='';
      if FlatSpinEditInteger1.Value <=0 then
      begin
        MsShow('请输入要导入的记录数!');
        Exit;
      end;  if BeginRow.Value <=0 then
      begin
        MsShow('请输入开始导入的行号!');
        Exit;
      end;  AllFileName :=FileListBox1.FileName;  if Trim(AllFileName)='' then
      begin
        MsShow('请选择Excel表格!');
        Exit;
      end;  Try
        FileName :=ExtractFileName(AllFileName);
        FilePath :=ExtractFilePath(AllFileName);
        FileExt  :=ExtractFileExt(AllFileName);
      Except
        Exit;
      end;  if GroupD.RecordCount>0  then
      begin
        if MsShow('是否删原来的记录,重新导入?',2)<>6 then exit ;
        DelGroupD;
      end;  try
        xlApp:=CreateOleObject('Excel.Application');
      except
        xlApp:=UnAssigned;
        MsShow('请重新安装Office 2000!');
        Exit;
      end;  try
        xlApp.Workbooks.Open(AllFileName);
      except
        MsShow ('打开Excel文档失败!');
        xlApp.Quit;
        xlApp:=UnAssigned;
        Exit;
      end;  Sheet:=xlApp.WorkBooks[1].WorkSheets[1]; //连接Sheet
      i :=BeginRow.Value;
      j :=FlatSpinEditInteger1.Value+BeginRow.Value ;
      try
        while i<=j do
        begin
          if trim(Sheet.cells.item[i,1])<>'' then
            begin
              GroupD.Insert;
                GroupD.FieldByName('Nationality').value :=Sheet.Cells.Item[i,2];//第i行第2列.
                ...... 
                ...... 
                ...... 
                ...... 
                ......           GroupD.Post;        end ;
            Inc(i);
        end;
      finally
        Msshow('数据导入完毕!');
      end;  try
        xlApp.Quit;
        Sheet :=Unassigned ;
        xlApp:=Unassigned;
      except  end;end;
      

  4.   

    谢谢楼上的代码
    不过这只是导入EXCEL的代码
    列间的字段的计算还没有实现啊,谢谢