(21-09-2022, Saat: 22:50)thợ kim hoàn63 Adlı Kullanıcıdan Alıntı: Merhaba;
Exceli açtığımız zaman etkinleştirme sihirbazı çıkıyorsa exceldeki veriyi çekerken 'Arama aranan tarafından kabul edilmedi' şeklinde hata mesajı ile karşılaşıyoruz. bu hatadan dolayı kayıtların bir kısmı çekilemiyor. bu hatayı delphi den devre dışı bırakmanın yada hatayı atlamanın bir yolu varmıdır.
verileri çekerken component kullanmıyorum. bir kodlama var onu kullanıyorum.
There are many examples of excel automation using delphi.
1- Import Excel, Office, ... Type Library (Excel_TLB.pas) and see it change for each Excel version in Excel_TBL.pas file
(e.g: // Hint: Symbol 'Application' renamed to 'ExcelApplication' )
2- Add Excel_TBL, Office_TBL as below
//--------------------------------------------------------------------------------------------------------------------------------
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Excel_TBL, Office_TBL;
//--------------------------------------------------------------------------------------------------------------------------------
and ComObj; as below
//--------------------------------------------------------------------------------------------------------------------------------
implementation
{$R *.dfm}
uses
ComObj;
//--------------------------------------------------------------------------------------------------------------------------------
Please google search: delphi + excel + Automation + Charlie Calvert.
There are two different ways to run OLE automation from inside Delphi:
You can create an instance of the object in these two different ways:
XLApp := Excel_TLB.CoApplication_.Create; // Initialize an interface
XLApp := CreateOleObject('Excel.Application'); // Initialize a Variant
One involves using interfaces, while the second involves using an OLE class called IDispatch along with a Delphi type called a variant. Interfaces give you the advantage of type checking your code on the client side, as well as relatively high performance. However, I am going to start the paper working with the somewhat easier to understand IDispatch and variants technology, and move on to cover interfaces after all the basics are clearly established. Do not worry if you don't yet understand the differences between the two techniques, as this subject will be cleared up over the course of the paper. At this stage, you just need to be aware that there are at least two ways to access OLE automation objects from Delphi, and that I am going to start out by showing you one that uses IDispatch and variants.
The following code, found in Listing 1, shows a bare bones example of a Delphi application that launches Excel. Just skim over the code for now, as I will spend the rest of this section of the paper explaining how it works.