Header menu logo ExcelProvider

Accessing Cells

To access a particular cell you need to access the relevant row and use the field name which is the value in the first row of the relevant column.

Example

alt text

This example demonstrates referencing the first column (with name Fourth) on row 4:

// reference the type provider
open FSharp.Interop.Excel

// Let the type provider do it's work
type MultipleSheetsSecond = ExcelFile<"MultipleSheets.xlsx", "B">
let file = new MultipleSheetsSecond()
let rows = file.Data |> Seq.toArray
let test = rows.[2].Fourth

And the variable test has the following value:

4.2

Cells can be accessed dynamically using the zero-based column index or case-sensitive header name:

let testByIndex = rows.[2].GetValue 0
let testByHeader = rows.[2].GetValue "Fourth"

The variables testByIndex and testByHeader have the respective values:

4.2
4.2

Accessing cell values by index or string header sacrifices type safety; the result signature is obj.

Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
namespace FSharp.Interop
namespace FSharp.Interop.Excel
type MultipleSheetsSecond = ExcelFile<...>
type ExcelFile = inherit ExcelFileInternal
<summary>Typed representation of data in an Excel file.</summary> <param name='FileName'>Location of the Excel file.</param> <param name='SheetName'>Name of sheet containing data. Defaults to first sheet.</param> <param name='Range'>Specification using `A1:D3` type addresses of one or more ranges. Defaults to use whole sheet.</param> <param name='HasHeaders'>Whether the range contains the names of the columns as its first line.</param> <param name='ForceString'>Specifies forcing data to be processed as strings. Defaults to `false`.</param>
val file: MultipleSheetsSecond
val rows: ExcelFile<...>.Row array
property ExcelFile<...>.Data: System.Collections.Generic.IEnumerable<ExcelFile<...>.Row> with get
module Seq from Microsoft.FSharp.Collections
val toArray: source: 'T seq -> 'T array
val test: float
val testByIndex: obj
val testByHeader: obj

Type something to start searching.