SharpCell.Grid

SheetLayout

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

SheetLayout()

public SheetLayout()

A layout with Excel's default sizes.

SheetLayout(double, double)

public SheetLayout(double defaultColumnWidth, double defaultRowHeight)

A layout with the given default sizes, in pixels.

Exceptions

Properties

DefaultColumnWidth

public double DefaultColumnWidth { get; set; }

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

Exceptions

DefaultRowHeight

public double DefaultRowHeight { get; set; }

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

Exceptions

Height

public double Height { get; }

The height of all rows together.

Width

public double Width { get; }

The width of all columns together.

Methods

ColumnAt(double)

public int ColumnAt(double x)

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

ColumnLeft(int)

public double ColumnLeft(int column)

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

Exceptions

ColumnWidth(int)

public double ColumnWidth(int column)

The width of a column.

Exceptions

ColumnWidthFromPixels(double, double)

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

Exceptions

FromWorksheet(Worksheet, double)

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

Exceptions

FromWorksheet(Worksheet, double, double)

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

Exceptions

RowAt(double)

public int RowAt(double y)

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

RowHeight(int)

public double RowHeight(int row)

The height of a row.

Exceptions

RowHeightFromPixels(double, double)

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

Exceptions

RowTop(int)

public double RowTop(int row)

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

Exceptions

SetColumnWidth(int, double)

public void SetColumnWidth(int column, double width)

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

Exceptions

SetRowHeight(int, double)

public void SetRowHeight(int row, double height)

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

Exceptions

VisibleArea(double, double, double, double)

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

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

Exceptions