Header menu logo ExcelProvider

Accessing Sheets

To access a particular sheet you need to specify the sheet name as the second parameter when creating the ExcelProvider type.

If you do not include a second parameter then the first sheet in the workbook is used.

Example

alt text

This example demonstrates referencing the second sheet (with name B):

// 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.[0].Fourth

And the variable test has the following value:

2.2
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

Type something to start searching.