SharpCell.Grid

GridClipboard

public static class GridClipboard

Namespace SharpCell.Grid · package SharpCell.Grid

What copying cells puts on the clipboard, in the forms Excel reads when it pastes, and the cells of text pasted from it. Copied are text with tabs between cells, and an HTML table that keeps fonts, fills, borders, alignment and merged cells. Cells are copied as shown, Cell.Text in their number format. Hidden rows and columns are copied, as Excel copies them. Whole columns or rows end at the sheet's used range.

Methods

Html(Worksheet, CellArea)

public static string Html(Worksheet sheet, CellArea area)

The cells as an HTML document with one table, whose cells carry their style inline and merged areas as colspan and rowspan; the table lies between the <!--StartFragment--> and <!--EndFragment--> comments. On macOS and Linux it goes on the clipboard as it is; Windows needs it wrapped by GridClipboard.WindowsHtml.

ReadText(string)

public static IReadOnlyList<IReadOnlyList<string>> ReadText(string text)

Text from the clipboard as rows of cells, the way Excel reads text it pastes: a tab between cells, a line break (\r\n or \n) between rows, the last line break ending the last row. A cell starting with a double quote runs to the closing one and may hold tabs and line breaks; two double quotes inside stand for one.

Text(Worksheet, CellArea)

public static string Text(Worksheet sheet, CellArea area)

The cells as text, as Excel puts them on the clipboard: a tab between cells, a line break after each row, the last one too. Text with a line break or a tab is put in double quotes, with any quote inside doubled.

WindowsHtml(string)

public static string WindowsHtml(string html)

HTML in the clipboard format Windows applications read, HTML Format: a header giving where the document and its fragment start and end, as byte offsets into its UTF-8 encoding, then the document. Put it on the clipboard as UTF-8 bytes.

Exceptions