Styles Alignment
Francois Botha edited this page Feb 26, 2018
·
3 revisions
var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Alignment");
// Automagically adjust the size of the comment to fit the contents
ws.Cell("A1").Comment.Style.Alignment.SetAutomaticSize();
ws.Cell("A1").Comment.AddText("Things are pretty tight around here");
// Default values
ws.Cell("A3").Comment
.AddText("Default Alignments:").AddNewLine()
.AddText("Vertical = Top").AddNewLine()
.AddText("Horizontal = Left").AddNewLine()
.AddText("Orientation = Left to Right");
// Let's change the alignments
ws.Cell("A8").Comment
.AddText("Vertical = Bottom").AddNewLine()
.AddText("Horizontal = Right");
ws.Cell("A8").Comment.Style
.Alignment.SetVertical(XLDrawingVerticalAlignment.Bottom)
.Alignment.SetHorizontal(XLDrawingHorizontalAlignment.Right);
// And now the orientation...
ws.Cell("D3").Comment.AddText("Orientation = Bottom to Top");
ws.Cell("D3").Comment.Style
.Alignment.SetOrientation(XLDrawingTextOrientation.BottomToTop)
.Alignment.SetAutomaticSize();
ws.Cell("E3").Comment.AddText("Orientation = Top to Bottom");
ws.Cell("E3").Comment.Style
.Alignment.SetOrientation(XLDrawingTextOrientation.TopToBottom)
.Alignment.SetAutomaticSize();
ws.Cell("F3").Comment.AddText("Orientation = Vertical");
ws.Cell("F3").Comment.Style
.Alignment.SetOrientation(XLDrawingTextOrientation.Vertical)
.Alignment.SetAutomaticSize();
// Set all comments to visible
ws.CellsUsed(true, c => c.HasComment).ForEach(c => c.Comment.SetVisible());
wb.SaveAs("CommentsAlignment.xlsx");
- 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