问题,数据库中的二进制文件导出。。第一步,ACCESS数据库中的二进制导出,word文档。第二步,获取导出的word文档,然后过滤一些特殊字符,变成txt存文本。第三步,连接到mysql数据库,并且插入到对应的字段。我弄2天了。还是没有解决,请高手帮我做一下,以前没接触过D,最好代码能全一些。
不够再加分。。在线等

解决方案 »

  1.   

    其实关键在第二步下面是转换代码,数据库取出与存入比较简单就不说了
    打开WORD文档var wordapp,doc:olevariant;
      I,iRow,iCol,IDHAO:INTEGER;
      NEWITEM:TLISTITEM;
      recostr,guidang,addgd,gdfile,filecopy:string;
    begin
    IF OpenDialog1.Execute THEN BEGIN
       Application.CreateForm(Tfind, find);
       find.Show;
       find.Update;
      LISTVIEW1.Clear ;
      IDHAO:=0;
      wordapp:=createoleobject('Word.application');
      doc:=wordapp.Documents.Open(FileName:=OpenDialog1.FileName);
      For i := 1 To doc.Tables.Count do
         For iRow := 2 To doc.Tables.Item(i).Rows.Count do begin
             NEWITEM:=LISTVIEW1.Items.Add ;
             IF LISTVIEW1.Items.Item[0].Caption='' THEN
                NEWITEM.Caption:=INTTOSTR(IDHAO)
             ELSE BEGIN
                  IDHAO:=IDHAO+1;
                  NEWITEM.Caption:=INTTOSTR(IDHAO);
             END;
             For icol := 1 To doc.Tables.Item(i).Columns.Count do begin
                 recostr:=doc.Tables.Item(i).Cell(iRow,icol).Range.Text;
                 while length(recostr) <> 0 do begin
                       filecopy:=Copy(recostr,1,Pos('',recostr)-1);
                       NEWITEM.SubItems.Add(filecopy) ;
                       delete(recostr,1,Pos('',recostr));
                  end;
             end;
                guidang:=doc.Paragraphs.item(2).range.text;
                while length(guidang) > 1 do begin
                      gdfile:=Copy(guidang,1,Pos(chr(13),guidang)-1);
                      delete(guidang,1,Pos(chr(13),guidang));
                end;
                gdfile:=gdfile+'-';
                addgd:=gdfile;
                while length(gdfile)<>0 do begin
                      guidang:=Copy(gdfile,1,Pos('-',gdfile)-1);
                      NEWITEM.SubItems.Add(guidang+chr(13)) ;
                      delete(gdfile,1,Pos('-',gdfile));
                end;
         end;
      wordapp.quit;保存为TXT文件VAR filename: textfile;
        I,J:INTEGER;
        newfile,zdfile,STR,FILECOPY,RECOSTR:STRING;
    begin
    IF SaveDialog1.Execute THEN BEGIN
       str := SaveDialog1.FileName;
       assignfile(FileName, str);
       if FileExists(str) then DeleteFile(SaveDialog1.FileName);
          ReWrite(filename);
          FOR I:=0 TO LISTVIEW1.Items.Count-1 DO BEGIN
              for j:=0 to listview1.Items[i].SubItems.Count -1 do begin
                  recostr:=listview1.Items[i].SubItems.Strings[j];
                  while length(recostr) <> 0 do begin
                       filecopy:=Copy(recostr,1,Pos(CHR(13),recostr)-1);
                       delete(recostr,1,Pos(CHR(13),recostr));
                       zdfile:=zdfile+filecopy;
                 end;
                 newfile:=newfile+zdfile+chr(14);
                 zdfile:='';
              end;
              Writeln(FileName, newfile);
              newfile:='';
          END;
    closefile(filename);
    APPLICATION.MessageBox('文 本 文 件 保 存 完 毕  !','系统提示',MB_OK+MB_ICONINFORMATION);