<!-- Generated by tools/SharpCell.Grid.Docs from the XML documentation comments. Do not edit; run the tool with 'generate'. -->

# SheetLayout

```csharp
public sealed class SheetLayout
```

Namespace `SharpCell.Grid` · package `SharpCell.Grid`

Where the cells of a sheet are, in device-independent pixels from the top-left corner of cell A1: column widths, row heights, their offsets, the cell under a point and the cells inside a viewport. Covers Excel's whole sheet, 1,048,576 rows by 16,384 columns. Rows and columns are numbered from 1.

## Constructors

<a id="ctor"></a>
### SheetLayout()

```csharp
public SheetLayout()
```

A layout with Excel's default sizes.

<a id="ctor-double-double"></a>
### SheetLayout(double, double)

```csharp
public SheetLayout(double defaultColumnWidth, double defaultRowHeight)
```

A layout with the given default sizes, in pixels.

**Exceptions**

- `ArgumentOutOfRangeException`: A size is not positive.

## Properties

<a id="defaultcolumnwidth"></a>
### DefaultColumnWidth

```csharp
public double DefaultColumnWidth { get; set; }
```

The width of every column without a width of its own.

**Exceptions**

- `ArgumentOutOfRangeException`: The width is not positive.

<a id="defaultrowheight"></a>
### DefaultRowHeight

```csharp
public double DefaultRowHeight { get; set; }
```

The height of every row without a height of its own.

**Exceptions**

- `ArgumentOutOfRangeException`: The height is not positive.

<a id="height"></a>
### Height

```csharp
public double Height { get; }
```

The height of all rows together.

<a id="width"></a>
### Width

```csharp
public double Width { get; }
```

The width of all columns together.

## Methods

<a id="columnat-double"></a>
### ColumnAt(double)

```csharp
public int ColumnAt(double x)
```

The column under a horizontal offset, clamped to the sheet; hidden columns are never hit.

<a id="columnleft-int"></a>
### ColumnLeft(int)

```csharp
public double ColumnLeft(int column)
```

The offset of a column's left edge; 0 for column A.

**Exceptions**

- `ArgumentOutOfRangeException`: The column is outside the sheet.

<a id="columnwidth-int"></a>
### ColumnWidth(int)

```csharp
public double ColumnWidth(int column)
```

The width of a column.

**Exceptions**

- `ArgumentOutOfRangeException`: The column is outside the sheet.

<a id="columnwidthfrompixels-double-double"></a>
### ColumnWidthFromPixels(double, double)

```csharp
public static double ColumnWidthFromPixels(double pixels, double maxDigitWidth)
```

The column width, in the units of `Worksheet.SetColumnWidth`, that Excel gives a column dragged to a width in pixels: `Truncate((c * d + 5) / d * 256) / 256` for `c = Truncate((pixels - 5) / d * 100 + 0.5) / 100` characters, as Excel shows it while dragging. Narrower than a digit and its padding, the smallest width that shows the pixels.

**Parameters**

- `pixels`: The width in pixels.
- `maxDigitWidth`: The width in pixels of the widest digit of the default font, at the zoom the pixels are at.

**Exceptions**

- `ArgumentOutOfRangeException`: The digit width is not positive, or the pixels are negative.

<a id="fromworksheet-worksheet-double"></a>
### FromWorksheet(Worksheet, double)

```csharp
public static SheetLayout FromWorksheet(Worksheet sheet, double maxDigitWidth)
```

A layout with a worksheet's column widths, row heights and hidden rows and columns, in pixels at 100% zoom as Excel converts them: a width of `w` characters is `Truncate((256 * w + Truncate(128 / d)) / 256 * d)` pixels, `d` being the width of the widest digit of the workbook's default font (7 for Calibri 11); a height of `h` points is `h * 96 / 72` pixels, rounded. Later changes to the sheet are not followed.

**Parameters**

- `sheet`: The sheet.
- `maxDigitWidth`: The width in pixels of the widest digit of the default font.

**Exceptions**

- `ArgumentOutOfRangeException`: The digit width is not positive.

<a id="fromworksheet-worksheet-double-double"></a>
### FromWorksheet(Worksheet, double, double)

```csharp
public static SheetLayout FromWorksheet(Worksheet sheet, double maxDigitWidth, double zoom)
```

A layout with a worksheet's sizes at a zoom, as Excel shows them: column widths from the digit width of the default font at that zoom, row heights in points times the zoom.

**Parameters**

- `sheet`: The sheet.
- `maxDigitWidth`: The width in pixels of the widest digit of the default font at the zoom.
- `zoom`: The zoom, 1 for 100%.

**Exceptions**

- `ArgumentOutOfRangeException`: The digit width or the zoom is not positive.

<a id="rowat-double"></a>
### RowAt(double)

```csharp
public int RowAt(double y)
```

The row under a vertical offset, clamped to the sheet; hidden rows are never hit.

<a id="rowheight-int"></a>
### RowHeight(int)

```csharp
public double RowHeight(int row)
```

The height of a row.

**Exceptions**

- `ArgumentOutOfRangeException`: The row is outside the sheet.

<a id="rowheightfrompixels-double-double"></a>
### RowHeightFromPixels(double, double)

```csharp
public static double RowHeightFromPixels(double pixels, double zoom)
```

The row height in points, as Excel stores it, of a row shown that many pixels high at a zoom.

**Parameters**

- `pixels`: The height in pixels.
- `zoom`: The zoom the pixels are at, 1 for 100%.

**Exceptions**

- `ArgumentOutOfRangeException`: The zoom is not positive, or the pixels are negative.

<a id="rowtop-int"></a>
### RowTop(int)

```csharp
public double RowTop(int row)
```

The offset of a row's top edge; 0 for row 1.

**Exceptions**

- `ArgumentOutOfRangeException`: The row is outside the sheet.

<a id="setcolumnwidth-int-double"></a>
### SetColumnWidth(int, double)

```csharp
public void SetColumnWidth(int column, double width)
```

Gives a column a width; zero hides it, the default width forgets the change.

**Exceptions**

- `ArgumentOutOfRangeException`: The column is outside the sheet, or the width is negative.

<a id="setrowheight-int-double"></a>
### SetRowHeight(int, double)

```csharp
public void SetRowHeight(int row, double height)
```

Gives a row a height; zero hides it, the default height forgets the change.

**Exceptions**

- `ArgumentOutOfRangeException`: The row is outside the sheet, or the height is negative.

<a id="visiblearea-double-double-double-double"></a>
### VisibleArea(double, double, double, double)

```csharp
public CellArea VisibleArea(double x, double y, double width, double height)
```

The cells that a rectangle of the sheet touches, partly or wholly.

**Exceptions**

- `ArgumentOutOfRangeException`: The width or height is negative.
