IExcelWorker
Defines a contract for working with Excel files, providing methods to manipulate cells, styles, sheets, and formatting.
Implementiert: IDisposable
Methoden
public IExcelWorker AddAreaChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddAreaChart(name, dataRange, anchorCol, anchorRow, width, height)
Adds an area chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddBarChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddBarChart(name, dataRange, anchorCol, anchorRow, width, height)
Adds a bar/column chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddBubbleChart(string name, string dataRange, int xCol, int yCol, int sizeCol, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddBubbleChart(name, dataRange, xCol, yCol, sizeCol, anchorCol, anchorRow, width, height)
Adds a bubble chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:C100") with X, Y, and size columns.
- xCol
- Column index for X-axis values (0-based).
- yCol
- Column index for Y-axis values (0-based).
- sizeCol
- Column index for bubble size values (0-based).
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddDoughnutChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddDoughnutChart(name, dataRange, anchorCol, anchorRow, width, height)
Adds a doughnut chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddLineChart(string name, string dataRange, int xCol, int yCol, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddLineChart(name, dataRange, xCol, yCol, anchorCol, anchorRow, width, height)
Adds a line chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- xCol
- Column index for X-axis values (0-based).
- yCol
- Column index for Y-axis values (0-based).
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddPieChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height, IEnumerable<string> colors)
result = iExcelWorker.AddPieChart(name, dataRange, anchorCol, anchorRow, width, height, colors)
Adds a pie chart whose slices are explicitly coloured, instead of using Office's automatic per-slice palette.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
- colors
- Per-slice colors (hex code or name) by slice index; the i-th color fills the i-th slice. Slices beyond the supplied colors (or whose color is empty) keep Office's automatic color.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddPieChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddPieChart(name, dataRange, anchorCol, anchorRow, width, height)
Adds a pie chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddRadarChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddRadarChart(name, dataRange, anchorCol, anchorRow, width, height)
Adds a radar (spider) chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddScatterChart(string name, string dataRange, int xCol, int yCol, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddScatterChart(name, dataRange, xCol, yCol, anchorCol, anchorRow, width, height)
Adds a scatter (XY) chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation (e.g., "A1:B100").
- xCol
- Column index for X-axis values (0-based).
- yCol
- Column index for Y-axis values (0-based).
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddSheet()
result = iExcelWorker.AddSheet()
Adds a new sheet to the workbook.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AddStockChart(string name, string dataRange, int anchorCol, int anchorRow, int width, int height)
result = iExcelWorker.AddStockChart(name, dataRange, anchorCol, anchorRow, width, height)
Adds a stock (OHLC) chart to the current sheet.
- name
- Chart title.
- dataRange
- Data range in A1 notation with Open, High, Low, Close columns.
- anchorCol
- Column where chart is anchored (0-based).
- anchorRow
- Row where chart is anchored (0-based).
- width
- Chart width in pixels.
- height
- Chart height in pixels.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker AutoFitColumn(int col)
result = iExcelWorker.AutoFitColumn(col)
Auto-fits the column width based on content.
- col
- The column index (0-based).
Rückgabe: The current IExcelWorker instance for method chaining.
public bool ContainsSheet(string name)
result = iExcelWorker.ContainsSheet(name)
Checks if a sheet with the specified name exists in the workbook.
- name
- The name of the sheet to check.
Rückgabe: true if the sheet exists; otherwise, false.
public IExcelWorker DeleteSheet(string name)
result = iExcelWorker.DeleteSheet(name)
Deletes a sheet by name.
- name
- The name of the sheet to delete.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker FreezeCols(int count)
result = iExcelWorker.FreezeCols(count)
Freezes the specified number of left columns.
- count
- The number of columns to freeze.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker FreezeRows(int count)
result = iExcelWorker.FreezeRows(count)
Freezes the specified number of top rows.
- count
- The number of rows to freeze.
Rückgabe: The current IExcelWorker instance for method chaining.
public T GetCell<T>(int col, int row)
result = iExcelWorker.GetCell(col, row)
Gets the value of a cell at the specified column and row.
- col
- The column index (0-based).
- row
- The row index (0-based).
Rückgabe: The value of the cell cast to type .
public int GetColumnsCount()
result = iExcelWorker.GetColumnsCount()
Gets the total number of columns in the current sheet.
Rückgabe: The number of columns.
public int GetRowsCount()
result = iExcelWorker.GetRowsCount()
Gets the total number of rows in the current sheet.
Rückgabe: The number of rows.
public IEnumerable<string> GetSheetNames()
result = iExcelWorker.GetSheetNames()
Gets the names of all sheets in the workbook.
Rückgabe: An enumerable of sheet names.
public IExcelWorker MergeCells(int startCol, int startRow, int endCol, int endRow)
result = iExcelWorker.MergeCells(startCol, startRow, endCol, endRow)
Merges cells in the specified range.
- startCol
- The starting column index (0-based).
- startRow
- The starting row index (0-based).
- endCol
- The ending column index (0-based).
- endRow
- The ending row index (0-based).
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker RenameSheet(string name)
result = iExcelWorker.RenameSheet(name)
Renames the current sheet to the specified name.
- name
- The new name for the sheet.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetCellColor(int col, int row, string bgColor, string fgColor)
result = iExcelWorker.SetCellColor(col, row, bgColor, fgColor)
Sets the colors of a specific cell.
- col
- The column index (0-based).
- row
- The row index (0-based).
- bgColor
- The background color (e.g., hex code or name).
- fgColor
- The foreground (text) color. If null, default is used.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetCellColor(int col, int row, string bgColor, ExcelFillPattern pattern, string patternColor, string fgColor)
result = iExcelWorker.SetCellColor(col, row, bgColor, pattern, patternColor, fgColor)
Sets the fill of a specific cell with an explicit pattern. Solid fills with ; any other pattern draws lines/dots over a background.
- col
- The column index (0-based).
- row
- The row index (0-based).
- bgColor
- The fill / background color (hex code or name).
- pattern
- The fill pattern.
- patternColor
- Pattern (lines/dots) color for a non-solid pattern. Defaults to black when empty. Ignored for Solid.
- fgColor
- The foreground (text) color. If null, default is used.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetCellFormat(int col, int row, string format)
result = iExcelWorker.SetCellFormat(col, row, format)
Sets the format of a specific cell.
- col
- The column index (0-based).
- row
- The row index (0-based).
- format
- The format string to apply.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetCell<T>(int col, int row, T value)
result = iExcelWorker.SetCell(col, row, value)
Sets the value of a cell at the specified column and row.
- col
- The column index (0-based).
- row
- The row index (0-based).
- value
- The value to set in the cell.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetColorScale(int col, int startRow, string minColor, string midColor, string maxColor)
result = iExcelWorker.SetColorScale(col, startRow, minColor, midColor, maxColor)
Sets a 3-color scale conditional formatting for a column (gradient from min to mid to max).
- col
- The column index (0-based).
- startRow
- The starting row for the formatting range (0-based, typically 1 to skip header).
- minColor
- Color for minimum values (hex, e.g., "F8696B" for red).
- midColor
- Color for middle values (hex, e.g., "FFEB84" for yellow).
- maxColor
- Color for maximum values (hex, e.g., "63BE7B" for green).
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetColumnWidth(int col, double width)
result = iExcelWorker.SetColumnWidth(col, width)
Sets the width of a column.
- col
- The column index (0-based).
- width
- The width in characters.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetConditionalFormatting(int col, ComparisonOperator op, string condition, string bgColor, string fgColor)
result = iExcelWorker.SetConditionalFormatting(col, op, condition, bgColor, fgColor)
Sets conditional formatting for a column based on a condition.
- col
- The column index (0-based).
- op
- The ComparisonOperator to use for the condition.
- condition
- The condition value as a string.
- bgColor
- The background color to apply if the condition is met (e.g., hex code or name).
- fgColor
- The foreground (text) color to apply if the condition is met (e.g., hex code or name).
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetConditionalFormattingFormula(int startCol, int startRow, int endCol, int endRow, string formula, ExcelConditionalFormat format)
result = iExcelWorker.SetConditionalFormattingFormula(startCol, startRow, endCol, endRow, formula, format)
Sets a formula-based ("expression") conditional formatting rule over a cell range, applying a full ExcelConditionalFormat (fill, font color/styles/size/name, number format and border) when the formula is true.
- startCol
- Range start column index (0-based).
- startRow
- Range start row index (0-based).
- endCol
- Range end column index (0-based).
- endRow
- Range end row index (0-based).
- formula
- Excel formula that returns TRUE to apply the format, without a leading '=' (e.g. $A2="OVERDUE").
- format
- The format to apply when the formula is true. Only the members that are set are written.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetConditionalFormattingFormula(int startCol, int startRow, int endCol, int endRow, string formula, string bgColor, string fgColor)
result = iExcelWorker.SetConditionalFormattingFormula(startCol, startRow, endCol, endRow, formula, bgColor, fgColor)
Sets a formula-based ("expression") conditional formatting rule over a cell range.
- startCol
- Range start column index (0-based).
- startRow
- Range start row index (0-based).
- endCol
- Range end column index (0-based).
- endRow
- Range end row index (0-based).
- formula
- Excel formula that returns TRUE to apply the format, without a leading '=' (e.g. $A2="OVERDUE").
- bgColor
- Background fill color applied when the formula is true (hex code or name). Optional.
- fgColor
- Foreground (text) color applied when the formula is true (hex code or name). If null, the font color is left unchanged.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetHyperlink(int col, int row, string url, string text)
result = iExcelWorker.SetHyperlink(col, row, url, text)
Sets a hyperlink in a cell.
- col
- The column index (0-based).
- row
- The row index (0-based).
- url
- The URL for the hyperlink.
- text
- The display text for the hyperlink. If null, the URL is used.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetRowHeight(int row, double height)
result = iExcelWorker.SetRowHeight(row, height)
Sets the height of a row.
- row
- The row index (0-based).
- height
- The height in points.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetStyle(int col, string format)
result = iExcelWorker.SetStyle(col, format)
Sets the style of a column using a custom format string.
- col
- The column index (0-based).
- format
- The format string to apply to the column.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SetStyle(int col, Type type)
result = iExcelWorker.SetStyle(col, type)
Sets the style of a column based on a specified type.
- col
- The column index (0-based).
- type
- The Type that determines the style.
Rückgabe: The current IExcelWorker instance for method chaining.
public IExcelWorker SwitchSheet(string name)
result = iExcelWorker.SwitchSheet(name)
Switches the active sheet to the one with the specified name.
- name
- The name of the sheet to switch to.
Rückgabe: The current IExcelWorker instance for method chaining.