各位大虾:
   你们好,我现在很急,公司有很多excel文件里面有很多数据,我想通过
 前端delphi程序来读取,然后保存到数据库后台,不知道有什么办法?请各位大师
 救救我!

解决方案 »

  1.   

    给你介绍个好帮助工具,里面有关于excel的处理方法。
    在Google里搜索《葵花宝典》,是delphi的帮助工具。很好用的。同时,也给你一个小例子吧。 var 
        bm: TBook; 
        col, row: Integer; 
        sline: String; 
        mem: TMemo; 
        ExcelApp: Variant; 
      begin 
        Screen.Cursor := crHourglass; 
        DBGrid1.DataSource.DataSet.DisableControls; 
        bm := DBGrid1.DataSource.DataSet.GetBook; 
        DBGrid1.DataSource.DataSet.First; 
      
        // create the Excel object 
        if toExcel then 
        begin 
          ExcelApp := CreateOleObject('Excel.Application'); 
          ExcelApp.WorkBooks.Add(xlWBatWorkSheet); 
          ExcelApp.WorkBooks[1].WorkSheets[1].Name := 'Grid Data'; 
        end; 
      
        // First we send the data to a memo 
        // works faster than doing it directly to Excel 
        mem := TMemo.Create(Self); 
        mem.Visible := false; 
        mem.Parent := MainForm; 
        mem.Clear; 
        sline := ''; 
      
        // add the info for the column names 
        for col := 0 to DBGrid1.FieldCount-1 do 
          sline := sline + DBGrid1.Fields[col].DisplayLabel + #9; 
        mem.Lines.Add(sline); 
      
        // get the data into the memo 
        for row := 0 to DBGrid1.DataSource.DataSet.RecordCount-1 do 
        begin 
          sline := ''; 
          for col := 0 to DBGrid1.FieldCount-1 do 
            sline := sline + DBGrid1.Fields[col].AsString + #9; 
          mem.Lines.Add(sline); 
          DBGrid1.DataSource.DataSet.Next; 
        end; 
      
        // we copy the data to the clipboard 
        mem.SelectAll; 
        mem.CopyToClipboard; 
      
        // if needed, send it to Excel 
        // if not, we already have it in the clipboard 
        if toExcel then 
        begin 
          ExcelApp.Workbooks[1].WorkSheets['Grid Data'].Paste; 
          ExcelApp.Visible := true; 
        end; 
      

  2.   

    to ggltechggl:
      不知道还笑别人,去搜吧,肯定对你有帮助的!!
      

  3.   


      我是通過delphi程序來讀取excel文件中的數據呀,而不是通過delphi把數據導出到
    excel中去。至於《葵花宝典》我去查查
      

  4.   

    我看了delphi《葵花宝典》評論,感覺不錯,我正在下載,怪我孤陋寡聞了,呵呵
      

  5.   

    这些读取方法都要安装Excel,能不能不安装Excel直接从文件中读取?