2021年11月12日 星期五

Can Delphi insert Excel 2007/2010 table

 

1) Delphi has no support for any Excel natively. It is all done with hands-tuned OCX import, and you can make your own import any time you need it!

Delphi Menu: Component / Import COmpionent / Type Library / excel.exe

2) but if you talk about Delphi XE2 it containsthat hand-tuned c:\RAD Studio\9.0\OCX\Servers\pas2010\Excel2010.pas for you

And thus Delphi has 3 design-time packages for you:

  • c:\RAD Studio\9.0\bin\dcloffice2010160.bpl
  • c:\RAD Studio\9.0\bin\dcloffice2K160.bpl
  • c:\RAD Studio\9.0\bin\dclofficexp160.bpl

https://winsoft.sk/officecs.htm 

https://sourceforge.net/directory/?q=delphi%20excel%20components

https://torry.net/pages.php?id=551

Delphi Easy Excel 基礎類別設計http://grandruru.blogspot.com/2020/03/delphi-easy-excel.html

https://edn.embarcadero.com/article/40813

https://delphi.fandom.com/wiki/3rd_Party_Components

https://github.com/sergio-hcsoft/Delphi-SpreadSheets

Regex library for Delphi

 https://github.com/shukomiya/skregexp

 

shukomiya/skregexp: Regex library for Delphi 2005 later
https://github.com › shukomiya › skregexp
 
Regex library for Delphi 2005 later. Contribute to shukomiya/skregexp development by creating an account on GitHub.

SKRegExp Trainer

 "Delphi 2005 以降で利用可能な SkRegExp (小宮さん作  SkRegExp 

https://ht-deko.com/tech053.html#DFMCONV

PerlRegExp Trainer

 Delphi XE から標準搭載された TPerlRegEx

VBSRegExp Trainer

 VBScript の TRegExp (正規表現クラス) の練習ツールです。

RegularExpressions Trainer

  • SkRegExp / PerlRegEx / VBSscript / RegularExpressions (FMX) 版すべて同じアーカイブ内に入っています。
  • VBScript 版は、他の 2 つと同じような動作にするために場当たり的な手法を採っています。
    あまり参考にしないで下さい&ちゃんとした使い方は Mr.XRAY さんとこの記事 を参考にして下さい。
  • VBScript 版をコンパイルするためには、タイプライブラリの取り込み ("Microsoft VBScript Regular Expressions 5.5") が必要です。
  • SkRegExp / VBSscript 版は Delphi 2009 以降でコンパイルできると思います。
  • PerlRegEx 版は Delphi XE 以降ですが、TPerlRegEx を別途 DL すれば Delphi 2009 以降
  • RegularExpressions (FMX) SkRegularExpressions / RegularExpressions 
  • TPerlRegEx   DH 山本さんの記事 

 

正規表現トレーナソースコード

 

 

 

 

Excel Creator Ver3.0 ( アドバンスソフトウェア製 )

 http://mrxray.on.coocan.jp/Delphi/plXLSOut/index.htm 

Excel 出力コンポーネント  

Excel Creator Ver3.0 ( アドバンスソフトウェア製 )
ExcelCreator Ver3.0 は,ExcelCreator 2007 に収録されている製品

http://mrxray.on.coocan.jp/Delphi/plExcelEx/index.htm

エクセル操作フォームEx
 

Microsoft Office Document Imaging (MODI) OCR

 
Microsoft Office Document Imaging (MODI)  OCR
regsvr32.exe mdivwctl.dll,

MDIVWCTL.DLL is part of MS office 2003.

OCR MODI Library (MDIVWCTL.DLL) is freely available


regsvr32.exe "C:\Program Files\Common Files\Microsoft Shared\MODI\11.0\mdivwctl.dll"
OFFICE2007 Files\Common Files\Microsoft Shared\MODI\12.0 MDIVWCTL.dll
C:\Program Files\Common Files\Microsoft Shared\MODI\11.0, 21MB
Install MODI for use with Microsoft Office
https://support.microsoft.com/en-us/topic/install-modi-for-use-with-microsoft-office-2010-4fbd3076-6d01-9cb7-c574-3bbabc9eead9

Microsoft Office Document Imaging 11.0 Type Library

CreateObject("MODI.Document")    
miDoc.Images(0).OCR miLANG_CHINESE_SIMPLIFIED, True, True '
 strLayoutInfo = _

        "Language: " & modiLayout.Language & vbCrLf & _

        "Number of characters: " & modiLayout.NumChars & vbCrLf & _

        "Number of fonts: " & modiLayout.NumFonts & vbCrLf & _

        "Number of words: " & modiLayout.NumWords & vbCrLf & _

        "Beginning of text: " & Left(modiLayout.Text, 50) & vbCrLf & _

        "First word of text: " & modiLayout.Words(0).Text

    MsgBox strLayoutInfo, vbInformation + vbOKOnly, "Layout Information"

    Set modiLayout = Nothing

    Set miDoc = Nothing

uses ...
ComObj, MODI_TLB


doc := CreateOleObject('MODI.Document') as IDocument;
 
CoCreateInstance(CLASS_Document,
                 NIL,
                 CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER,
                 IDocument,
                 doc);

Var
  doc :IDocument;
  Img :IImage;
  Layout :ILayout;
begin
  doc := IDispatch(CreateOleObject('MODI.Document')) as IDocument;
  doc.create(FileName);  // just put here the filename of an image
  doc.OCR(miLANG_ENGLISH,true,true);
  Img := IDispatch(doc.Images[0]) as IImage;
  Layout := IDispatch(Img.Layout) as ILayout;
  Memo1.Lines.Add(Layout.Text);
  MiDocView1.Document := doc;
  doc.Close(false);
  Img := nil;
  Layout := nil;

    Screen.MousePointer = vbDefault


https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2003/aa202819(v=office.11)


try
        if CoCreateInstance(CLASS_Document,
                            NIL,
                            CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER,
                            IDocument,
                            fMODIdoc)<>S_OK then
          begin
            Application.MessageBox(sNoMODIDocIntf,sMODI,MB_OK+MB_ICONSTOP);
            Exit;
          end;
        fMODIdoc.Create(WideString(ImgName));
        try
          if ( xxxxx  ) then LangID:=miLANG_HUNGARIAN                                                               else LangID:=miLANG_ENGLISH;
          (fMODIdoc.Images[0] as IImage).OCR(LangID,FALSE,FALSE);
          for i:=0 to (fMODIdoc.Images[0] as IImage).Layout.Words.Count-1 do
            begin
              aWord:=(fMODIdoc.Images[0] as IImage).Layout.Words[i] as IWord;
              nRects:=aWord.Rects;
              for j:=0 to nRects.Count-1 do
                begin
                  aRect:=nRects.Item[j] as IMiRect;
                  if (p.X>=aRect.Left)   and
                     (p.X<=aRect.Right)  and
                     (p.Y>=aRect.Top)    and
                     (p.Y<=aRect.Bottom) then
                    begin
                      Result:=aWord.Text;
                      Exit;
                    end;
                end;
            end;
        finally
          fMODIdoc.Close(FALSE);
        end;
      except
      end;
var
 modi: olevariant;
 fname: TFileName;   //MDIVWCTL.DLL http://www.microsoft.com/ru-ru/download/confirmation.aspx?id=21581
 i: integer;
 s: string;
begin
 fname:= '1.tif';
 modi:= CreateOLEObject('MODI.Document');
 modi.Create(fname);

 modi.OCR();
 s:= '';
 for i:= 0 To modi.Images.Count - 1 do  
  s:= s+ modi.Images(i).Layout.Text;  
 showmessage(s);
 //showmessage(modi.images.item(0).layout.text);
 modi.close;
 modi:= UnAssigned;  
end;

https://social.msdn.microsoft.com/Forums/en-US/29093b50-1f09-4b5e-9f41-c0f4a540852f/using-modi-microsoft-office-document-imaging-how-to-get-images-and-table-in-text-file?forum=worddev


using MODI (Microsoft Office Document Imaging) how to get images and table in text file

MODI and OpenXML SDK

http://www.codeproject.com/KB/office/OCRSampleApplication.aspx

&

This sample project demonstrates how to export, delete and replace the images in a document by using Open XML SDK

http://code.msdn.microsoft.com/CSManipulateImagesInWordDoc-312da7ef

I hope this helps.
https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2003/aa167607(v=office.11)?redirectedfrom=MSDN
Using the Microsoft Office Document Imaging 2003 Object Model

// CCMD_OCRView.cpp : implementation of the CCCMD_OCRView class

// CCMD_OCRView.cpp : implementation of the CCCMD_OCRView class
//
#include "stdafx.h"
#include "CCMD_OCR.h"
#include "CCMD_OCRDoc.h"
#include "CCMD_OCRView.h"
#include "../class/global.h"//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "mdivwctl.h"
enum MiLANGUAGES
{ miLANG_CHINESE_SIMPLIFIED = 2052,
  miLANG_CHINESE_TRADITIONAL = 1028,
  miLANG_CZECH = 5,
  miLANG_DANISH = 6,
  miLANG_DUTCH = 19,
  miLANG_ENGLISH = 9,
  miLANG_FINNISH = 11,
  miLANG_FRENCH = 12,
  miLANG_GERMAN = 7,
  miLANG_GREEK = 8,
  miLANG_HUNGARIAN = 14,
  miLANG_ITALIAN = 16,
  miLANG_JAPANESE = 17,
  miLANG_KOREAN = 18,
  miLANG_NORWEGIAN = 20,
  miLANG_POLISH = 21,
  miLANG_PORTUGUESE = 22,
  miLANG_RUSSIAN = 25,
  miLANG_SPANISH = 10,
  miLANG_SWEDISH = 29,
  miLANG_SYSDEFAULT = 2048,
  miLANG_TURKISH = 31
};
enum MiFILE_FORMAT
{ miFILE_FORMAT_DEFAULTVALUE = -1,
  miFILE_FORMAT_TIFF = 1,
  miFILE_FORMAT_TIFF_LOSSLESS = 2,
  miFILE_FORMAT_MDI = 4
};
enum MiCOMP_LEVEL
{ miCOMP_LEVEL_LOW = 0,
  miCOMP_LEVEL_MEDIUM = 1,
  miCOMP_LEVEL_HIGH = 2
};
/////////////////////////////////////////////////////////////////////////////
// CCCMD_OCRView

IMPLEMENT_DYNCREATE(CCCMD_OCRView, CFormView)

BEGIN_MESSAGE_MAP(CCCMD_OCRView, CFormView)
    //{{AFX_MSG_MAP(CCCMD_OCRView)
    ON_WM_PAINT()
    ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
    ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
    ON_COMMAND(ID_FILE_NEW, OnFileNew)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()