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
--
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...
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>...
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.
"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
> 1. How do I export from Excel 2000 into a database?
Regards,
--
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