Writing value to excel

Hi All,

I must be missing something since the code below produces an exception.  How 
do I write a simple value to an excel file using ADO.  Thanks  Bob

  ADOTable := TADOTable.Create(application);
  ADOTable.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source='+
                                Fname+';Extended Properties="Excel 
8.0;HDR=NO;IMEX=1"';
  ADOTable.readonly := False;

  try
    try
      (* Summary Sheet Data Load *)
      ADOTable.tablename := '[Sheet1$]';
      ADOTable.active := True;

      ADOTable.First;

     ADOTable.edit;
      for col := 1 to 3 do
      begin
        ADOTable.Fields.FieldByNumber(col).value := 3;
      end;
      ADOTable.Next;
0
Bob
11/10/2008 5:14:52 PM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

3 Replies
898 Views

Similar Articles

[PageSpeed] 35

Your code looks ok
What exception are you getting?


> {quote:title=Bob McKinnon wrote:}{quote}
> Hi All,
> 
> I must be missing something since the code below produces an exception.  How 
> do I write a simple value to an excel file using ADO.  Thanks  Bob
> 
>   ADOTable := TADOTable.Create(application);
>   ADOTable.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data 
> Source='+
>                                 Fname+';Extended Properties="Excel 
> 8.0;HDR=NO;IMEX=1"';
>   ADOTable.readonly := False;
> 
>   try
>     try
>       (* Summary Sheet Data Load *)
>       ADOTable.tablename := '[Sheet1$]';
>       ADOTable.active := True;
> 
>       ADOTable.First;
> 
>      ADOTable.edit;
>       for col := 1 to 3 do
>       begin
>         ADOTable.Fields.FieldByNumber(col).value := 3;
>       end;
>       ADOTable.Next;
0
Brian
11/11/2008 3:07:30 AM
Thanks for the reply,

I have it working now. It was in my connection string,  I had to remove the 
IMEX=1 and then it all work.  I have a few questions:

Is there any good reference information on using ADOTable on the internet or 
at least some good examples?

When the vale is saved into the Excel file it is left justified rather than 
the standard right justification.  Any way to set this?

IT does not like to save a string to the excel file, it basically ignores 
the string.
 ADOTable.Fields.FieldByNumber(col).astring := '3';  //Works
 ADOTable.Fields.FieldByNumber(col).astring := 'Three';  //Does not work

Your help is appreciated,

Bob




<Brian Bushay> wrote in message news:41870@forums.codegear.com...
> Your code looks ok
> What exception are you getting?
>
>
>> {quote:title=Bob McKinnon wrote:}{quote}
>> Hi All,
>>
>> I must be missing something since the code below produces an exception. 
>> How
>> do I write a simple value to an excel file using ADO.  Thanks  Bob
>>
>>   ADOTable := TADOTable.Create(application);
>>   ADOTable.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data
>> Source='+
>>                                 Fname+';Extended Properties="Excel
>> 8.0;HDR=NO;IMEX=1"';
>>   ADOTable.readonly := False;
>>
>>   try
>>     try
>>       (* Summary Sheet Data Load *)
>>       ADOTable.tablename := '[Sheet1$]';
>>       ADOTable.active := True;
>>
>>       ADOTable.First;
>>
>>      ADOTable.edit;
>>       for col := 1 to 3 do
>>       begin
>>         ADOTable.Fields.FieldByNumber(col).value := 3;
>>       end;
>>       ADOTable.Next;
0
Bob
11/11/2008 2:39:27 PM
> {quote:title=Bob McKinnon wrote:}{quote}
> Thanks for the reply,
> 
> I have it working now. It was in my connection string,  I had to remove the 
> IMEX=1 and then it all work.  I have a few questions:
> 
> Is there any good reference information on using ADOTable on the internet or 
> at least some good examples?
I do not believe this is possible
> 
> When the vale is saved into the Excel file it is left justified rather than 
> the standard right justification.  Any way to set this?
My observations have been that ADO does not give you control over formating.
Althoug this URL might help you some
http://www.dicks-blog.com/archives/2004/06/03/


> IT does not like to save a string to the excel file, it basically ignores 
> the string.
>  ADOTable.Fields.FieldByNumber(col).astring := '3';  //Works
>  ADOTable.Fields.FieldByNumber(col).astring := 'Three';  //Does not work


> Your help is appreciated,
> 
> Bob
> 
> 
> 
> 
> <Brian Bushay> wrote in message news:41870@forums.codegear.com...
> > Your code looks ok
> > What exception are you getting?
> >
> >
> >> {quote:title=Bob McKinnon wrote:}{quote}
> >> Hi All,
> >>
> >> I must be missing something since the code below produces an exception. 
> >> How
> >> do I write a simple value to an excel file using ADO.  Thanks  Bob
> >>
> >>   ADOTable := TADOTable.Create(application);
> >>   ADOTable.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data
> >> Source='+
> >>                                 Fname+';Extended Properties="Excel
> >> 8.0;HDR=NO;IMEX=1"';
> >>   ADOTable.readonly := False;
> >>
> >>   try
> >>     try
> >>       (* Summary Sheet Data Load *)
> >>       ADOTable.tablename := '[Sheet1$]';
> >>       ADOTable.active := True;
> >>
> >>       ADOTable.First;
> >>
> >>      ADOTable.edit;
> >>       for col := 1 to 3 do
> >>       begin
> >>         ADOTable.Fields.FieldByNumber(col).value := 3;
> >>       end;
> >>       ADOTable.Next;
0
Brian
11/12/2008 12:58:03 AM
Reply:

Similar Artilces:

Write the value of datatable to excel
 How to write the value of DataTable into Excel by HTML Text Writer ?? Someone Please Help me ... Thanks You ...   1    Private Sub ExportToExcel(ByVal strColumnName As String)2    3            Dim GVRow As GridViewRow4            Dim dtable As DataTable = New DataTable5    6            If strColumnName IsNot Nothing AndAlso strColumnName.Length <> 0 Then7    8 ...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

how to insert a textbox value into an excel sheet using excel.workbook object in a windows application and read a value from a particular cell
Hi EveryOne , Im in problem im working on windows application n im sorry to post my problem here i ddint find any onther alternate solution so i have to do this , ne ways im working on an windows application i need to export the data ebtered into the textbox1 to a particular cell of an excel sheet and this will generate a value in an another excel sheet so i hav to read that value from that cell and display bac to the another textbox of my application from that excel file so how to do it and i have been adviced to dis by using excel workbook and im not much aware of it so plz can u ppl hel...

How to write value to a single MS excel cell from c# code?
Hi all... I need to write hard-coded value "my value" in cell "C24" to an already existing MS excel sheet. Is it possible tht i can write a function in which i just have to pass the "C24" AND "MY VALUE" and hence it wud write the value to the corresponding cell?? so far i have done this...  private void browseButton_Click(object sender, EventArgs e) {Excel.Application objApp; Excel.Workbook objBook;Excel.Sheets objSheets; Excel._Worksheet workSheet;Excel.Range range;   // prepare open file dialog to only search for ...

Excel value in excel xp and later
Hi: In trhe excel xp and 2003 typelibraries the value property of a range object is declared as: function Get_Value(RangeValueDataType: OleVariant; lcid: Integer; out RHS: OleVariant): HResult; What is the first parameter? And how can I determine whethe I should use range.value, or range.text? Chers Sean. Sean Farrow <> wrote in news:66310@forums.codegear.com: > Hi: > In trhe excel xp and 2003 typelibraries the value property of a range > object is declared as: > function Get_Value(RangeValueDataType: OleVariant; lcid: Integer; > out RHS: OleV...

session value not working, but hard coding value works, but session value writes to label correctly
I add a value to the session in the parent window:Session("value1") = value.text.trim()I have a button on a that page opening a popup window using javascript.In the popup window I get the value from the session:Protected Sub Page_Load......Dim ValueDesc As String = Session.Item("value1") Label1.Text = ValueDesc (This shows the correct value for ValueDesc)I then get the first 3 char of ValueDescDim SearchString As String = Left(ValueDesc, 3) Label2.Text = SearchString (This shows the correct value for SearchString)I then pass SearchString to a Protected Sub:BindtoGrid(Sear...

Aspose.Excel 1.9 Released!
Aspose.Excel 1.9 Released! Version 1.9 Released on April 6, 2004. Added: Chart API enhancement (DataLabels setting, Axis Title setting, Legend position setting, PlotArea position setting, etc.) Added: Insert Row/Column API support Added: Delete Row/Column API support Added: Cells.ExportDataTableAsString method Added: Ungroup Row/Column API support Added: Multi-port license support Added: LOOKUP function support in formula Added: Style.ShrinkToFit Added: Print Area/Titles setting Added: Clear range API Enhanced: Speed up Autofit method and Cell.Formula ...

Aspose.Excel 2.5 Released!
Aspose.Excel 2.5 Released! Version 2.5.0.0 Released on November 09 2004 ...

Aspose.Excel 2.8 Released!
Aspose.Excel 2.8 Released! Version 2.8.0.0 Released on January 20 2005 Version 2.8.0.0 includes all the features provided in Hot Fix 2.7.* while the following is a quick list. Added: Exporting e...

Aspose.Excel 2.9 Released!
Aspose.Excel 2.9 Released! Version 2.9 Released on March 12 2005 Version 2.9 includes all the features provided in Hot Fix 2.8.* while the following is a quick list. ...

Aspose.Excel 2.7 Released!
Aspose.Excel 2.7 Released! Version 2.7.0.0 Released on December 14 2004 Version 2.7.0.0 includes all the features provided in Hot Fix 2.6.* while the following is a ...

Aspose.Excel 2.4 Released!
Aspose.Excel 2.4 Released! Version 2.4.0.0 Released on October 11 2004 Version 2.4.0.0 includes all the features provided in Hot Fix 2.3.* while the following is a ...

Aspose.Excel 2.1 Released!
Aspose.Excel 2.1 Released! Version 2.1.0.0 Released on July 03 2004 Version 2.1.0.0 includes all the features provided in Hot Fix 2.0.* while the following is a quick list. Added: Custom Chart API Added: Worksheets.GetRangeByName method Added: Worksheet.CopyConditionalFormatting method Added: CEILING, OR function support in Cell.Formula Added: Hyperlinks.AddInternalLink method Added: NSeries.IsColorVaried Added: Worksheet.Index Added: EndCell methods in Cells class Added: Worksheets.IsSheetTabsShown property Fixed: A bug of opening certain kind...

Aspose.Excel 2.0 Released!
Aspose.Excel 1.9 Released! Version 2.0.0.0 Released on June 09 2004 Version 2.0.0.0 includes all the features provided in Hot Fix 1.9.* while the following is a quick list. Added: Chart API enhancement (Axis line and area setting, etc.) Added: ExcelXP protection API Added: Cells.ImportDataView, Cells.ImportObjectArray Added: Range.Unmerge method Added: Find methods in Cells class Added: Hide row/column methods Added: Worksheets.AddCopy method Changed: License setting mode Enhanced: Converting formula in designer file to string Enhanced: Absolut reference...

Web resources about - Writing value to excel - embarcadero.delphi.ado

Pulitzer Prize for Feature Writing - Wikipedia, the free encyclopedia
1979: Jon D. Franklin , Baltimore Evening Sun , for ' Mrs. Kelly's Monster ', "an account of brain surgery ." 1981: Teresa Carpenter , Village ...

Writing as therapy: how blogs and memoirs can help the sick and traumatized
Whether the the inky cousin of selfie culture, or the long tail of the creative writing mania, writing as therapy is having a moment. Can it ...

Student writing: grade 4 students explore animal rights
St Kilda Primary School students have been learning the power of persuasive writing. Here three students explore shark culling and horse racing. ...

Review: Apple Pencil is the best iPad writing tool yet … if you can handle the Pro’s size
... While Pencil is not required to use the iPad Pro, it’s especially interesting because it’s Apple’s first official solution for handwriting, ...

Don't Lose Confidence in Your Writing
... originally published on November 20th. Mel You're as good as anyone else! That's usually the opening to blog posts about how to keep on writing, ...

16 Tips on Blog Writing and Formatting
... same ideas over and over again. My point is that you ought to take advice with a grain of salt. And that applies to this post as well. Writing ...

On Gratitude and Writing Your Own Story
... after all this, it’s time that I realize that my story only needs me to complete it. I don’t need to wait for my story to be written. I’m writing ...

Jaden Smith ‘sees himself as a modern-day prophet’ & he’s writing a book
I feel sorry for the Smith kids, Jaden and Willow. They have all that money, access and potential, and they’re just… struggling, I think. Part ...

App turns your writing into trippy 3D images
It's easy to imagine a piece of art in your head, but making it real is another matter if you're not an artist. Wouldn't it be nice if you could ...

"Goodnight Mommy" Directors Are Re-Writing The Rules Of Horror
And the Academy just may take notice. Aside from categories like Best Makeup and Best Visual Effects, horror films aren't usually among the ...

Resources last updated: 12/7/2015 10:03:51 PM