Board index » delphi » How do I get the total Record Counts of Excel

How do I get the total Record Counts of Excel


2005-01-03 01:54:51 PM
delphi34
Hi everyone,
I am using OLE Automation to read datas from Excel files.
But i don't know how to detect the total RecordCounts of every Sheet .
Thanks!
PS: I am using Delphi5.0 Enterprise Edition
bill
 
 

Re:How do I get the total Record Counts of Excel

I'm not sure what information you need but this can help I hope:
LSheet.Range['A1:C10'].Value := 'X';
LRange := LSheet.UsedRange;
LSheet.Range['A12'].Value := 'UsedRange: ' + LRange.Address;
LSheet.Range['A13'].Value := 'UsedRange Rows: ' +
IntToStr(LRange.Rows.Count);
LSheet.Range['A14'].Value := 'UsedRange Columns: ' +
IntToStr(LRange.Columns.Count);
"bill" <XXXX@XXXXX.COM>writes
Quote
Hi everyone,
I am using OLE Automation to read datas from Excel files.
But i don't know how to detect the total RecordCounts of every Sheet .

Thanks!

PS: I am using Delphi5.0 Enterprise Edition

bill



 

Re:How do I get the total Record Counts of Excel

Hi,
Sorry for my poor English!
And, Thank you very much. Your methold seems worked!
I just want to get the rows numbers of Excel file that has data in the
cell.
The " nRowCount := LSheet.UsedRange.Rows.Count; " did it!
Thank you again!
bill
"Mariusz Celmer" <XXXX@XXXXX.COM>在郵件
Quote
I'm not sure what information you need but this can help I hope:

LSheet.Range['A1:C10'].Value := 'X';
LRange := LSheet.UsedRange;
LSheet.Range['A12'].Value := 'UsedRange: ' + LRange.Address;
LSheet.Range['A13'].Value := 'UsedRange Rows: ' +
IntToStr(LRange.Rows.Count);
LSheet.Range['A14'].Value := 'UsedRange Columns: ' +
IntToStr(LRange.Columns.Count);


"bill" <XXXX@XXXXX.COM>writes
news:41d8dcac$XXXX@XXXXX.COM...
>Hi everyone,
>I am using OLE Automation to read datas from Excel files.
>But i don't know how to detect the total RecordCounts of every Sheet .
>
>Thanks!
>
>PS: I am using Delphi5.0 Enterprise Edition
>
>bill
>
>
>


 

Re:How do I get the total Record Counts of Excel

in this situation my example will works only if your data records are
continously filled in the worksheet, I mean in example from row 1 to 50
without empty rows. If there would be some empty rows (rows without data)
then my example return the same value.
Do you have some empty rows (records) in worksheets you like to count in,
and do you need to count them also or not?
Mariusz
"bill" <XXXX@XXXXX.COM>writes
Quote
Hi,
Sorry for my poor English!
And, Thank you very much. Your methold seems worked!
I just want to get the rows numbers of Excel file that has data in the
cell.
The " nRowCount := LSheet.UsedRange.Rows.Count; " did it!
Thank you again!
bill




"Mariusz Celmer" <XXXX@XXXXX.COM>在郵件
news:XXXX@XXXXX.COM 中撰寫...
>I'm not sure what information you need but this can help I hope:
>
>LSheet.Range['A1:C10'].Value := 'X';
>LRange := LSheet.UsedRange;
>LSheet.Range['A12'].Value := 'UsedRange: ' + LRange.Address;
>LSheet.Range['A13'].Value := 'UsedRange Rows: ' +
>IntToStr(LRange.Rows.Count);
>LSheet.Range['A14'].Value := 'UsedRange Columns: ' +
>IntToStr(LRange.Columns.Count);
>
>
>"bill" <XXXX@XXXXX.COM>writes
>news:41d8dcac$XXXX@XXXXX.COM...
>>Hi everyone,
>>I am using OLE Automation to read datas from Excel files.
>>But i don't know how to detect the total RecordCounts of every Sheet
.
>>
>>Thanks!
>>
>>PS: I am using Delphi5.0 Enterprise Edition
>>
>>bill
>>
>>
>>
>
>


 

Re:How do I get the total Record Counts of Excel

Yes, it could be some empty rows in worksheets and i also need to count
them .
So the example returns the same value is just what i want.
Thank you very much.
bill
"Mariusz Celmer" <XXXX@XXXXX.COM>在郵件
Quote
in this situation my example will works only if your data records are
continously filled in the worksheet, I mean in example from row 1 to 50
without empty rows. If there would be some empty rows (rows without data)
then my example return the same value.

Do you have some empty rows (records) in worksheets you like to count in,
and do you need to count them also or not?

Mariusz


"bill" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>Hi,
>Sorry for my poor English!
>And, Thank you very much. Your methold seems worked!
>I just want to get the rows numbers of Excel file that has data in the
>cell.
>The " nRowCount := LSheet.UsedRange.Rows.Count; " did it!
>Thank you again!
>bill
>
>
>
>
>"Mariusz Celmer" <XXXX@XXXXX.COM>在郵件
>news:XXXX@XXXXX.COM 中撰寫...
>>I'm not sure what information you need but this can help I hope:
>>
>>LSheet.Range['A1:C10'].Value := 'X';
>>LRange := LSheet.UsedRange;
>>LSheet.Range['A12'].Value := 'UsedRange: ' + LRange.Address;
>>LSheet.Range['A13'].Value := 'UsedRange Rows: ' +
>>IntToStr(LRange.Rows.Count);
>>LSheet.Range['A14'].Value := 'UsedRange Columns: ' +
>>IntToStr(LRange.Columns.Count);
>>
>>
>>"bill" <XXXX@XXXXX.COM>writes
>>news:41d8dcac$XXXX@XXXXX.COM...
>>>Hi everyone,
>>>I am using OLE Automation to read datas from Excel files.
>>>But i don't know how to detect the total RecordCounts of every
Sheet
.
>>>
>>>Thanks!
>>>
>>>PS: I am using Delphi5.0 Enterprise Edition
>>>
>>>bill
>>>
>>>
>>>
>>
>>
>
>