Article View: borland.public.cppbuilder.database.ado
Article #1864Re: ADO and Excel
From: Lee
Date: Sun, 25 Jan 2004 12:23
Date: Sun, 25 Jan 2004 12:23
79 lines
3495 bytes
3495 bytes
Viatcheslav,
Thank you for your responce, although I am not really sure that I understand
it.
Here is what I have:
//Creates the excel file
String CB1 = ComboBox2->Text.SetLength(ComboBox2->Text.Length() -4);
String reportName = CB1 +"_"+ ComboBox3->Text+ ".xls";
Variant XL;
XL= CreateOleObject("Excel.Application");
XL.OlePropertySet("Visible",false);
XL.OlePropertySet("DisplayAlerts",false);
XL.OlePropertyGet("Workbooks").OleProcedure("Add");
//Delets the file if it exists
if (FileExists(GetCurrentDir()+"\\"+reportName))
{
DeleteFile(GetCurrentDir()+"\\"+reportName);
}
//save the new file
XL.OleProcedure("Save",GetCurrentDir()+"\\"+reportName);
XL.OleFunction("Quit");
Data->ExcelTable->ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+reportName+";"
"Extended Properties=Excel 8.0;Persist Security Info=False";
Data->ExcelTable->Fields->Fields['A1']->AsString = "Hello";
I am getting an EListError with message "list index out of bounds" error
now. I have the sheet name typed in to the properties of the ADO table
component as Sheet1$
Thank you for your help
Lee
"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
news:401265f9$1@newsgroups.borland.com...
> Create ADO connection with connection string:
>
> Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\MyFile.xls;Extended
> properties=Excel 8.0
>
> Excel 5.0 for MS Excel 5/95 speadsheet
>
> Create TADODataSet, TADOTable or TADOQuery and connect to speadsheet.
Table
> name is [DiapasonName] for named diapason, [$Sheet1] for sheet,
> [Sheet1$B5:C10] for cell range.
>
> Work with TADODataSet (TADOTable, TADOQuery) as usual. If you do not want
> SQL even if it is hidden from you use server-side cursor (client-side
cursor
> will create and execute SQL commands internally).
>
> //------------------------------------------
> Regards,
> Vassiliev V. V.
> http://www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
> http://www.oledbdirect.com - The fastest way to access MS SQL Server,
> MS Jet (Access) and Interbase (through OLEDB)
>
> "Lee" <golee@charter.net> �������/�������� � �������� ���������:
> news:4012423b$1@newsgroups.borland.com...
> > Does any one know if I can post information into an excel spread sheet
> with
> > out using SQL, but using straight ADO connection. I am using BCB5 Ent
> and
> > if it can be done, could I get a code sample? Thanks
> >
> > Thanks
> >
> >
>
>
Technical Details
Message-ID:
<4013b534$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4012423b$1@newsgroups.borland.com> <401265f9$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,84d0342e6b56816d X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-01-25 04:39:13 PST From: "Lee" <golee@charter.net> Newsgroups: borland.public.cppbuilder.database.ado References: <4012423b$1@newsgroups.borland.com> <401265f9$1@newsgroups.borland.com> Subject: Re: ADO and Excel Date: Sun, 25 Jan 2004 04:23:08 -0800 Lines: 81 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 66.189.208.82 Message-ID: <4013b534$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1075033396 66.189.208.82 (25 Jan 2004 04:23:16 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail