Peter Sippel
Guest
|
Hi,
I'm not sure what's the best way to access the cell values. For example, to get all values in the first row:
This one is extremly slow:
arrHdr[i-1] := ExcelApp.Cells.Value[1,i];
This one is obviously not possible, although mentioned in another topic in this forum:
arrHdr[i-1] := ExcelApp.Cells[1,i];
This one fires an exception:
arrHdr[i-1] := ExcelApp.Cells.Text[1,i];
This one works good, but it's not so easy to get the column Name (AB, AC, ...) dynamically
arrHdr[i-1] := ExcelApp.Range['A'+inttostr(i),EmptyParam].Value;
As there's no reference for VCL, please advice the best way to access the cell values
TIA.
Peter |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Peter,
This part relates to using the Excel object model, not Add-in Express.
You need to construct a range containing required cells and call ExcelRange.Value. This returns an OleVariant containg values of all cells from the first area of the range.
Andrei Smolin
Add-in Express Team Leader |
|
Peter Sippel
Guest
|
Hi Andrei,
I understand that you can't give support for the MS Object Model. But this is related to how the VCL AddIn Express Components works.
In AddIn .net you can use "Range.Cells[row, col].Value" for example, in VBA you can use similar "Cells(row,col).Value". In VCL it's not possible to use it like that, as Cells is no array and no fuction. It's implemented as a Range.
Unfortunately there's no VCL reference and I don't have the source subscription. Also here in the forum I couldn't find anything about that. So how can I get to know, how AddIn Express for VCL works and which functions or vars etc. I should use ?
I don't think it's a highly sophisticated task to access the cell values, Addin Express is all about this kind of stuff, isn't it ?
So if you have one example with the best approach to use Addin Express for VCL to get/set the cell values, this would help very much and would be highly appreciated.
Thanks
Peter |
|
Peter Sippel
Guest
|
Hi Andrei,
I get good results, using Cells.Value[Row,Col] property of different ranges. So the problem above was obviously the use of ExcelApp.Cells.Value, which is probably ALL cells of the app and hence, very slow.
I seem to begin to understand a bit how Addin Express works and what's related to COM.
I'm very impressed of what you can achieve with the Addin Express Library. Thanks a lot for that.
Rgds
Peter |
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Peter,
Thank you for the nice words!
Andrei Smolin
Add-in Express Team Leader |
|