Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Import from Excel 2000 to Delphi 5

445 views
Skip to first unread message

Marcelo Muzilli

unread,
Mar 26, 2003, 7:20:38 PM3/26/03
to
Hello all,

I have a sheet in Excel 2000 and I would like to import the data
from Excel (2000) to a DBGrid object for example, in an application that
I will develop in Delphi 5.
Somebody knows how can I do this?

Thanks in advance,

Marcelo Muzilli
UIN: 1572797
mmuz...@ig.com.br

Mike Shkolnik

unread,
Mar 27, 2003, 1:12:17 AM3/27/03
to
SMImport suite: http://www.scalabium.com/smi

--
With best regards, Mike Shkolnik
E-mail: mshk...@scalabium.com
WEB: http://www.scalabium.com

"Marcelo Muzilli" <mmuz...@dreamtheater.zzn.com> wrote in message
news:3E8243D6...@dreamtheater.zzn.com...

Marcelo Muzilli

unread,
Mar 27, 2003, 7:45:55 AM3/27/03
to
Hi Mike,
Yes, I know this suite, but I need a free code. This is the reason
for the help.

Deborah, if you could help me I will thank you.

What I need?
I need to open a .XLS file, import some cells from a sheet to a
database (Paradox, for example).

Regards,

Marcelo Muzilli
UIN: 1572797
mmuz...@ig.com.br

"Mike Shkolnik" <mshkol...@ukr.net> wrote in message news:<3e82...@newsgroups.borland.com>...

Marcelo Muzilli

unread,
Mar 27, 2003, 8:30:50 AM3/27/03
to
Hi people,
look my code. I'm trying to develop using a help in the "Deborah
Pate's Page" (http://www.djpate.freeserve.co.uk/AutoExcl.htm#OpenWorkbook),
but when I run it, it give me a error message "Old format or invalid
type library".

What it means?
I have a old type library for the function syntax?

Regards,

Marcelo Muzilli
UIN: 1572797
mmuz...@ig.com.br

SOURCE CODE:
------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, OleServer, Excel2000;

type
TForm1 = class(TForm)
Excel: TExcelApplication;
WBk: TExcelWorkbook;
WS: TExcelWorksheet;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Excel: _Application;
AppWasRunning: boolean; // tells you if you can close Excel when
you've finished
lcid: integer;
Unknown: IUnknown;
Result: HResult;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
WBk: _Workbook;
WS: _WorkSheet;
Filename: OleVariant;
begin
LCID := GetUserDefaultLCID;
Filename := 'C:\Test.xls';
WBk := Excel.Workbooks.Open(Filename, EmptyParam, EmptyParam,
EmptyParam, EmptyParam,
EmptyParam,
EmptyParam, EmptyParam,
EmptyParam,
EmptyParam, EmptyParam,
EmptyParam,
EmptyParam, LCID);
WS := WBk.Worksheets.Item['Sheet1'] as _Worksheet;
WS.Activate(LCID);
end;

end.

Ken White

unread,
Mar 27, 2003, 1:35:49 PM3/27/03
to
Marcelo,

"Marcelo Muzilli" <mmuz...@dreamtheater.zzn.com> wrote in message
news:3E8243D6...@dreamtheater.zzn.com...

> I have a sheet in Excel 2000 and I would like to import the data
> from Excel (2000) to a DBGrid object for example, in an application
that
> I will develop in Delphi 5.
> Somebody knows how can I do this?

Your question doesn't make sense, I'm afraid... A TDBGrid is designed to
display data already stored in a database of some sort, and therefore
has no storage of it's own. Therefore, you cannot "import the data" into
a TDBGrid object.

So, I can think of two interpretations of your question:

1. How do I export from Excel 2000 into a database?
2. How do I view an Excel 2000 sheet in a TDBGrid?

If one of the above is your actual question, I'm sure I (or someone else
here) can answer it.

If neither of the above is your question, please re-submit it with
additional detail so we can understand it.

Ken
---
Ken White
kwh...@adpsi.com

Clipper Functions for Delphi and C++ Builder
http://www.adpsi.com

Marcelo Muzilli

unread,
Mar 27, 2003, 8:43:54 PM3/27/03
to
Hi Ken,
answering your question: my question refers to the number 01:

> 1. How do I export from Excel 2000 into a database?

Regards,

--

Marcelo Muzilli

unread,
Mar 27, 2003, 8:13:37 PM3/27/03
to
Hi Ken,
answering your question: my question refers to the number 01:

> 1. How do I export from Excel 2000 into a database?

Regards,

--

Marcelo Muzilli
UIN: 1572797
mmuz...@ig.com.br

Oliver Townshend

unread,
Mar 28, 2003, 3:11:52 AM3/28/03
to
> > 1. How do I export from Excel 2000 into a database?

An Excel file can be created as an ODBC link, which you could then read
through a TTable. This will only work if it is well structured.

You could save it as a text file, eg a tab delimited (.txt) or comma
delimited (.csv) file which you could then read with a TTable or something
like that.

If you have SQL-Server, then DTS will let you copy the file directly into
the database.

Oliver Townshend

valentin tihomirov

unread,
Mar 31, 2003, 10:38:22 AM3/31/03
to
Connect to Excel application, read data from it and put them into your
DBGrid


0 new messages