ExcelBuilder

ExcelBuilder Class

Properties:

  1. Workbook:

    • Type: XLWorkbook
    • Accessibility: public
    • Description: Gets the underlying ClosedXML workbook instance.
  2. Worksheets:

    • Type: Worksheet[]
    • Accessibility: public
    • Description: Gets an array of Worksheet instances associated with the ExcelBuilder.

Constructor:

  1. ExcelBuilder(params Worksheet[] worksheets)

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelBuilder class. It creates a new XLWorkbook, sets the provided Worksheets, and initializes components by adding worksheets to the workbook.
    Methods:
  2. Datasets(params ExcelTable[] tables)

    • Accessibility: public static
    • Return Type: IExcelBuilder
    • Description: Creates a new ExcelBuilder instance with one worksheet named "data" and specified Excel tables.
  3. Datasets(string workSheetName, params ExcelTable[] tables)

    • Accessibility: public static
    • Return Type: IExcelBuilder
    • Description: Creates a new ExcelBuilder instance with one worksheet and specified name, along with Excel tables.
  4. Datasets(params Worksheet[] worksheets)

    • Accessibility: public static
    • Return Type: IExcelBuilder
    • Description: Creates a new ExcelBuilder instance with specified worksheets.
  5. Build()

    • Accessibility: public
    • Return Type: IExcelExtractor
    • Description: Builds the Excel workbook based on the specified worksheets and tables. It iterates through the worksheets and their tables, updating styles and merging cells as needed.

IDisposable Implementation:

  1. Dispose()
    • Accessibility: public
    • Description: Disposes of the ExcelBuilder instance and associated resources.

Save and Stream Methods:

  1. SaveAsFile(string fileName)

    • Accessibility: public
    • Return Type: IDisposable
    • Description: Saves the Excel workbook to a file with the specified file name. Updates styles before saving.
  2. GetStream()

    • Accessibility: public
    • Return Type: MemoryStream
    • Description: Gets the Excel workbook as a memory stream. Updates styles before obtaining the stream.

Worksheet

Here is the breakdown for the Worksheet class, starting with the constructor, followed by properties, and then methods:

Constructor:

Accessibility: public Description: Initializes a new instance of the Worksheet class with the specified name and associated Excel tables.

Properties:

  1. ShowGridLines Property:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether gridlines should be displayed in the worksheet. The default is false.
  2. Name Property:

    • Type: string
    • Accessibility: public
    • Description: Gets the name of the worksheet.
  3. Tables Property:

    • Type: IEnumerable<ExcelTable>
    • Accessibility: public
    • Description: Gets an enumerable collection of Excel tables associated with the worksheet.
  4. ColumnsWidth Property:

    • Type: List<double>
    • Accessibility: public
    • Description: Gets or sets a list of column widths associated with the worksheet. The default is an empty list.

ExcelTable

ExcelTable

Constructor:

Accessibility: public Description: Initializes a new instance of the ExcelTable class. It creates new lists for columns and rows.

Properties:

  1. AlignTableEnd Property:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether the table should be aligned at the end of the worksheet and with respect to previous table.
  2. EmptyRowsBeforePresentation Property:

    • Type: int
    • Accessibility: public
    • Description: Gets or sets the number of empty rows to be added before presenting the table.
  3. Columns Property:

    • Type: List<ExcelColumn>
    • Accessibility: public
    • Description: Gets a list of ExcelColumn associated with the table.
  4. Rows Property:

    • Type: List<ExcelRow>
    • Accessibility: public
    • Description: Gets or sets a list of ExcelRow instances associated with the table.
  5. MaxCellsCount Property:

    • Type: int
    • Accessibility: public
    • Description: Gets the maximum number of cells among all rows in the table.
  6. StartColumnNumber Property:

    • Type: int
    • Accessibility: public
    • Description: Gets the starting column number for the table.
  7. LastColumnNumber Property:

    • Type: int
    • Accessibility: public
    • Description: Gets the last column number for the table.
  8. StartingRowNumber Property:

    • Type: int
    • Accessibility: public
    • Description: Gets the starting row number for the table.
  9. LastRowNumber Property:

    • Type: int
    • Accessibility: public
    • Description: Gets the last row number for the table.
  10. LinkedTable Property:

    • Type: ExcelTable
    • Accessibility: public
    • Description: Gets or sets the linked table associated with the current table.

Methods:

  1. GetColumn Method:

    • Accessibility: public
    • Description: Gets the ExcelColumn with the specified column name or actual name.
  2. GetColumn Method:

    • Accessibility: public
    • Description: Gets the ExcelColumn with the specified column number.
  3. Link Method:

    • Accessibility: public
    • Description: Links the current table to another ExcelTable.

ExcelRow

ExcelRow Class:

Constructor:

  1. Default Constructor:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelRow class with an empty list of cells and the default row style.
  2. Constructor with Cell Values:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelRow class with specified cell values. Calls the default constructor internally.
  3. Constructor with RowStyle and Cell Values:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelRow class with a specified row style and cell values. Calls the default constructor internally.
  4. Constructor with RowStyle:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelRow class with a specified row style. Calls the default constructor internally.

Properties:

  1. Cells:

    • Type: List<ExcelCell>
    • Accessibility: public
    • Description: Gets or sets a list of ExcelCell instances associated with the row.
  2. RowStyle:

    • Type: RowStyle
    • Accessibility: public
    • Description: Gets or sets the RowStyle for the row.
  3. SpanRowToMaxColumns:

    • Type: bool
    • Accessibility: public
    • Description: Gets a value indicating whether the row should span to the maximum number of columns.
  4. IsFrozen:

    • Type: bool
    • Accessibility: public
    • Description: Gets a value indicating whether the row is frozen.
  5. RowNumber:

    • Type: int
    • Accessibility: internal
    • Description: Gets or sets the row number.

Methods:

  1. SpanToMaxRowCells:

    • Accessibility: public
    • Description: Sets the SpanRowToMaxColumns property to true.
  2. Freeze:

    • Accessibility: public
    • Description: Freezes the row.

Now, let's proceed to the ExcelColumn class.

ExcelColumn

ExcelColumn Class:

Constructor:

  1. Constructor with ColumnName and ActualColumnName:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelColumn class with the specified column name, actual column name, and the default column style.
  2. Constructor with ColumnName, ActualColumnName, and ColumnStyle:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelColumn class with the specified column name, actual column name, and column style.

Properties:

  1. ColumnName:

    • Type: string
    • Accessibility: public
    • Description: Gets the name of the column.
  2. ActualName:

    • Type: string
    • Accessibility: public
    • Description: Gets the actual name of the column.
  3. ColumnStyle:

    • Type: ColumnStyle
    • Accessibility: public
    • Description: Gets or sets the ColumnStyle for the column.
  4. ColumnNumber:

    • Type: int
    • Accessibility: internal
    • Description: Gets the column number.
  5. SpannedLastColumnNumber:

    • Type: int
    • Accessibility: internal
    • Description: Gets the spanned last column number.

ExcelStyle

ExcelStyle Class:

Constructor:

  1. Default Constructor:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelStyle class.
  2. Constructor with AllowCellsToBeBordered:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelStyle class with the specified option to allow cells to be bordered.

Properties:

  1. FontBold:

    • Type: bool?
    • Accessibility: public
    • Description: Gets or sets a value indicating whether the font is bold.
  2. AlignmentHorizontal:

    • Type: XLAlignmentHorizontalValues?
    • Accessibility: public
    • Description: Gets or sets the horizontal alignment.
  3. AlignmentVertical:

    • Type: XLAlignmentVerticalValues?
    • Accessibility: public
    • Description: Gets or sets the vertical alignment.
  4. BackroundColor:

    • Type: XLColor?
    • Accessibility: public
    • Description: Gets or sets the background color.
  5. FontColor:

    • Type: XLColor?
    • Accessibility: public
    • Description: Gets or sets the font color.
  6. FontSize:

    • Type: double
    • Accessibility: public
    • Description: Gets or sets the font size.
  7. TopBorder:

    • Type: XLBorderStyleValues?
    • Accessibility: public
    • Description: Gets or sets the top border style.
  8. BottomBorder:

    • Type: XLBorderStyleValues?
    • Accessibility: public
    • Description: Gets or sets the bottom border style.
  9. LeftBorder:

    • Type: XLBorderStyleValues?
    • Accessibility: public
    • Description: Gets or sets the left border style.
  10. RightBorder:

    • Type: XLBorderStyleValues?
    • Accessibility: public
    • Description: Gets or sets the right border style.
  11. AddCellsToSpan:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether cells should be added to the span.
  12. AllowCellsToBeBordered:

    • Type: bool?
    • Accessibility: public
    • Description: Gets or sets a value indicating whether cells are allowed to be bordered.

Methods:

  1. UpdateStyleTo:
    • Accessibility: public virtual
    • Description: Updates the given IXLStyle with the style properties.

ColumnStyle

ColumnStyle Class:

Constructor:

  1. Default Constructor:
    • Accessibility: public
    • Description: Initializes a new instance of the ColumnStyle class.

Properties:

  1. Width:
    • Type: int
    • Accessibility: public
    • Description: Gets or sets the width of the column.

CellStyle

CellStyle Class:

Constructor:

  1. Constructor with AllowCellsToBeBordered:
    • Accessibility: public
    • Description: Initializes a new instance of the CellStyle class with the specified option to allow cells to be bordered.

Properties:

  1. Colspan:

    • Type: int
    • Accessibility: public virtual
    • Description: Gets or sets the column span.
  2. Rowspan:

    • Type: int
    • Accessibility: public virtual
    • Description: Gets or sets the row span.
  3. IsWrapped:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether text in the cell is wrapped.

Methods:

  1. UpdateStyleTo:
    • Accessibility: public override
    • Description: Updates the given IXLStyle with the style properties, including wrap text.

RowStyle

RowStyle Class:

Constructor:

  1. Constructor with AllowCellsToBeBordered:
    • Accessibility: public
    • Description: Initializes a new instance of the RowStyle class with the specified option to allow cells to be bordered.

Properties:

  1. Height:
    • Type: double
    • Accessibility: public
    • Description: Gets or sets the height of the row.

ExcelCell

ExcelCell Class:

Constructor:

  1. Default Constructor:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelCell class with the default cell style and an empty rich text.
  2. Constructor with CellStyle:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelCell class with the specified cell style.
  3. Constructor with Value:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelCell class with the specified cell value.
  4. Constructor with RichText:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelCell class with the specified rich text.
  5. Constructor with RichText and CellStyle:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelCell class with the specified rich text and cell style.
  6. Constructor with Value and CellStyle:

    • Accessibility: public
    • Description: Initializes a new instance of the ExcelCell class with the specified cell value and cell style.

Properties:

  1. CellStyle:

    • Type: CellStyle
    • Accessibility: public
    • Description: Gets or sets the CellStyle for the cell.
  2. Value:

    • Type: string
    • Accessibility: public
    • Description: Gets or sets the value of the cell.
  3. CellNumber:

    • Type: int
    • Accessibility: internal
    • Description: Gets the cell number.
  4. RichText:

    • Type: RichText
    • Accessibility: public
    • Description: Gets or sets the rich text associated with the cell.

RichTextValue

RichTextValue Class:

Properties:

  1. Bold:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether the text is bold.
  2. FontColor:

    • Type: XLColor?
    • Accessibility: public
    • Description: Gets or sets the font color.
  3. Italic:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether the text is italicized.
  4. StrikeThrough:

    • Type: bool
    • Accessibility: public
    • Description: Gets or sets a value indicating whether the text has a strikethrough.
  5. Value:

    • Type: string
    • Accessibility: public
    • Description: Gets or sets the text value.
  6. UpdateStyleTo:

    • Accessibility: public
    • Description: Updates the style of an IXLRichString with the properties of the RichTextValue.

RichText

RichText Class:

Constructor:

  1. Default Constructor:
    • Accessibility: public
    • Description: Initializes a new instance of the RichText class with an empty list of RichTextValue instances.

Properties:

  1. HashValue:
    • Type: bool
    • Accessibility: public
    • Description: Gets a value indicating whether the rich text has any values.

Methods:

  1. Add:

    • Accessibility: public
    • Description: Adds a RichTextValue to the list.
  2. AddALine:

    • Accessibility: public
    • Description: Adds a newline character to the last RichTextValue in the list.
  3. GetValues:

    • Accessibility: public
    • Description: Returns an enumerable collection of RichTextValue instances.

This concludes the breakdown for the ExcelCell, RichTextValue, and RichText classes. Let me know if you'd like to proceed with another class.

ExcelCollectionEx

ExcelCollectionEx Class:

Extension Methods:

  1. AddCell Method (1):

    • Accessibility: public static
    • Description: Adds a new ExcelCell with the specified value to the collection.
  2. AddCell Method (2):

    • Accessibility: public static
    • Description: Adds a new ExcelCell with the specified value and ExcelTable.CellStyle to the collection. If AddCellsToSpan is true in the provided cellStyle, additional cells are added to the collection to match the colspan.
  3. AddCell Method (3):

    • Accessibility: public static
    • Description: Adds a new ExcelCell with the specified value and ExcelTable.CellStyle to the ExcelRow collection. If AddCellsToSpan is true in the provided cellStyle, additional cells are added to the row to match the colspan.
  4. Values Method:

    • Accessibility: public static
    • Description: Returns an array of string values from the ExcelRow by extracting values from each ExcelCell.
  5. AddColumn Method:

    • Accessibility: internal static
    • Description: Adds a new ExcelColumn to the collection with the specified column name, actual column name, and ExcelTable.ColumnStyle.
  6. AddCell Method (4):

    • Accessibility: public static
    • Description: Adds a new empty ExcelCell to the ExcelRow collection.
  7. Add Method (1):

    • Accessibility: public static
    • Description: Adds a new ExcelRow to the collection with the specified cell values.
  8. Add Method (2):

    • Accessibility: public static
    • Description: Adds a new empty ExcelRow to the collection. It is intended for representing an empty row.
  9. Add Method (3):

    • Accessibility: public static
    • Description: Adds a new ExcelRow to the collection with the specified row style and cell values.
  10. Add Method (4):

    • Accessibility: public static
    • Description: Adds a new ExcelRow to the collection with the specified ExcelTable.CellStyle and cell values.
  11. Add Method (5):

    • Accessibility: public static
    • Description: Adds a new ExcelRow to the collection with the specified ExcelTable.RowStyle, ExcelTable.CellStyle, and cell values.
  12. Add Method (6):

    • Accessibility: public static
    • Description: Adds a collection of ExcelCell to the ExcelRow collection.
  13. Add Method (7):

    • Accessibility: public static
    • Description: Adds a collection of ExcelCell to the ExcelRow collection with the specified ExcelTable.RowStyle.
  14. AddRange Method (1):

    • Accessibility: public static
    • Description: Adds a range of ExcelTable.ExcelCell to the collection with the specified ExcelTable.CellStyle and cell values.
  15. AddRange Method (2):

    • Accessibility: public static
    • Description: Adds a range of ExcelCell to the ExcelRow collection.
  16. AddRange Method (3):

    • Accessibility: public static
    • Description: Adds a range of ExcelCell to the ExcelRow collection with the specified ExcelTable.RowStyle.