<κλάση header="doc-nav" aria-label="Πλοήγηση τεκμηρίωσης">
Τεκμηρίωση HotXLS
<κλάση nav="doc-links">
Περιεχόμενα
Αρχική
Επισκόπηση
TGridToXLS
IXLSWorkbook
<κλάση div="nav topic-quick-nav" aria-label="Topic shortcuts">
Αρχική
Περιεχόμενα
Επισκόπηση
Referring to Cells by using Index numbers
<κλάση div="indent">
<κλάση div="txt">
You can use the Cells property to refer to a single cell by using row and column index numbers. This property returns a Range object that represents a single cell
Παράδειγμα
<κλάση div="indent">
<κλάση div="txt">
In the following example, Cells[5,2] returns cell B5 on Sheet1. The Value property is then set to 10
<κλάση pre="code">
Workbook.Sheets[1].Cells[5,2].Value := 10;
<κλάση div="txt">
The Cells property works well for looping through a range of cells, as shown in the following example
<κλάση pre="code">
With Workbook.Sheets[1] do begin
for i := 1 to 10 do
Cells[i, 1].Value := i;
end;
<κλάση div="txt">
The Cells property can be applied to Range object, as shown in the following example
<κλάση pre="code">
With Workbook.Sheets[1].Range['C5', 'G20'] do begin
for i := 1 to Rows.Count do
Cells[i, 1].Value := i;
end;
<κλάση div="txt">
This example loops through cells C5:H15 on Sheet1. If a cell contains a value less than 0.1, the example replaces that value with 0
<κλάση pre="code">
With Workbook.Sheets[1].Range['C5', 'H15'] do begin
for i := 1 to Rows.Count do
for j := 1 to Columns.Count do
if Cells[i, j].Value < 0.1 then Cells[i, j].Value := 0;
end;
<κλάση footer="reference-footer">Copyright © 2010-2026 losLab Software