Dokumentacija HotXLS Sadržaj Početna Pregled TGridToXLS IXLSWorkbook Početna Sadržaj Pregled

Referring to Cells by using Index numbers

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

Primjer

In the following example, Cells[5,2] returns cell B5 on Sheet1. The Value property is then set to 10 Workbook.Sheets[1].Cells[5,2].Value := 10; The Cells property works well for looping through a range of cells, as shown in the following example With Workbook.Sheets[1] do begin for i := 1 to 10 do Cells[i, 1].Value := i; end; The Cells property can be applied to Range object, as shown in the following example With Workbook.Sheets[1].Range['C5', 'G20'] do begin for i := 1 to Rows.Count do Cells[i, 1].Value := i; end; 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 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; Copyright © 2010-2026 losLab Software