- Notifications
You must be signed in to change notification settings - Fork906
Merging Cells
Francois Botha edited this pageFeb 26, 2018 ·3 revisions

varworkbook=newXLWorkbook();varws=workbook.Worksheets.Add("Merge Cells");// Merge a rowws.Cell("B2").Value="Merged Row(1) of Range (B2:D3)";ws.Range("B2:D3").Row(1).Merge();// Merge a columnws.Cell("F2").Value="Merged Column(1) of Range (F2:G8)";ws.Cell("F2").Style.Alignment.WrapText=true;ws.Range("F2:G8").Column(1).Merge();// Merge a rangews.Cell("B4").Value="Merged Range (B4:D6)";ws.Cell("B4").Style.Alignment.Horizontal=XLAlignmentHorizontalValues.Center;ws.Cell("B4").Style.Alignment.Vertical=XLAlignmentVerticalValues.Center;ws.Range("B4:D6").Merge();// Unmerging a range...ws.Cell("B8").Value="Unmerged";ws.Range("B8:D8").Merge();ws.Range("B8:D8").Unmerge();workbook.SaveAs("MergeCells.xlsx");
varmergedRange=ws.MergedRanges.First(r=>r.Contains("B4"));mergedRange.Style.Fill.BackgroundColor=XLColor.Red;
- How do I deliver an Excel file in ASP.NET?
- Does it support Excel 2003 and prior formats (.xls)?
- How can I insert an image?
- Text with numbers are getting converted to numbers, what's up with that?
- How do I get the result of a formula?
- Data Types
- Creating Multiple Worksheets
- Organizing Sheets
- Loading and Modifying Files
- Using Lambda Expressions
- Cell Values
- Workbook Properties
- Using Formulas
- Evaluating Formulas
- Creating Rows And Columns Outlines
- Hide Unhide Rows And Columns
- Freeze Panes
- Copying Worksheets
- Using Hyperlinks
- Data Validation
- Hide Worksheets
- Sheet Protection
- Tab Colors
- Conditional Formatting
- Pivot Table example
- Sparklines
- Copying IEnumerable Collections
- Inserting Data
- Inserting Tables
- Adding DataTable as Worksheet
- Adding DataSet
- Styles - Alignment
- Styles - Border
- Styles - Fill
- Styles - Font
- Styles - NumberFormat
- NumberFormatId Lookup Table
- Style Worksheet
- Style Rows and Columns
- Using Default Styles
- Using Colors
- ClosedXML Predefined Colors
- Excel Indexed Colors
- Using Rich Text
- Using Phonetics
- Defining Ranges
- Merging Cells
- Clearing Ranges
- Deleting Ranges
- Multiple Ranges
- Shifting Ranges
- Transpose Ranges
- Named Ranges
- Accessing Named Ranges
- Copying Ranges
- Using Tables
- Sorting Data
- Selecting Cells and Ranges
- Row Height and Styles
- Selecting Rows
- Inserting Rows
- Inserting and Deleting Rows
- Adjust Row Height and Column Width to Contents
- Row Cells
- Column Width and Styles
- Selecting Columns
- Inserting Columns
- Inserting and Deleting Columns
- Adjust Row Height and Column Width to Contents
- Column Cells
- Pages Tab
- Paper Size Lookup Table
- Margins Tab
- Headers and Footers Tab
- Sheet Tab
- Print Areas and Page Breaks