Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Databases > Convert Excel c...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 974 of 986
Post > Topic >>

Convert Excel coordinates

by Dario <dtinazzi@[EMAIL PROTECTED] > Oct 12, 2007 at 03:59 AM

Hi, if I'm OT here please indicate me the right ng.

I'm trying to access a cell on an Excel sheet via ADO using R1C1 type
coordinates; I've a TADOTable, i set the proper connection string:

....
  qXLS2 := TADOTable.Create(Self);
  conXLS := TADOConnection.Create(Self);
  conXLS.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=' + Trim(FileName) + ';' +
    'Extended Properties="Excel 8.0;HDR=NO;IMEX=1";Persist Security
Info=False';
  conXLS.LoginPrompt := FALSE;
  qXLS2.Connection := conXLS;
  qXLS2.TableDirect := TRUE;
....

then I read the coordinates (row and column) from another table:

....
  R := qXLS1.FieldByName('Row').AsInteger;
  C := qXLS1.FieldByName('Column').AsInteger;
  SheetZone := 'R' + IntToStr(R) + 'C' + IntToStr(C);
  SheetZone := SheetZone + ':' + SheetZone;
  try
    qXLS2.Active := FALSE;
    qXLS2.TableName := SheetName + '$' + SheetZone;
    qXLS2.Active := TRUE;
  except
    on E: Exception do
    begin
      MessageDlg(E.Message, mtError, [mbOk], 0);
      EXIT;
    end;
  end;
....

You see I use a syntax like: "Sheet1$R1C1:R1C1" in the TableName
attribute, but I see it's not proper because I obtain an error
message; I know that a string like "Sheet1$A1:A1" is ok and doesn't
give me errors, so I'd like to find a way to use the R1C1 coordinates
in the TableName attribute or a way to convert all the R1C1 type
coordinates in corresponding A1 coordinates.

Can anyone help me?

TIA

Dario
 




 1 Posts in Topic:
Convert Excel coordinates
Dario <dtinazzi@[EMAIL  2007-10-12 03:59:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 0:31:40 CDT 2008.