Establishes the foundational structure, core Excel functionality, and tooling. - Implements base components for cells, ranges, columns, and rows. - Integrates a custom calculation engine with a wide range of Excel functions. - Adds comprehensive support for styling, conditional formatting, data validation, comments, pictures, and charts. - Configures build setup, project metadata (NuGet), and developer guidelines. - Includes editor and Git attributes for consistent code style and line endings.
106 lines
2.2 KiB
C#
106 lines
2.2 KiB
C#
using System;
|
|
using ClosedXML.Excel;
|
|
|
|
|
|
namespace ClosedXML_Examples.Styles
|
|
{
|
|
public class StyleAlignment : IXLExample
|
|
{
|
|
#region Variables
|
|
|
|
// Public
|
|
|
|
// Private
|
|
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
// Public
|
|
|
|
// Private
|
|
|
|
// Override
|
|
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
// Public
|
|
public StyleAlignment()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
// Private
|
|
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
// Public
|
|
|
|
// Private
|
|
|
|
// Override
|
|
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
// Public
|
|
public void Create(String filePath)
|
|
{
|
|
var workbook = new XLWorkbook();
|
|
var ws = workbook.Worksheets.Add("Style Alignment");
|
|
|
|
var co = 2;
|
|
var ro = 1;
|
|
|
|
ws.Cell(++ro, co).Value = "Horizontal = Right";
|
|
ws.Cell(ro, co).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
|
|
|
|
ws.Cell(++ro, co).Value = "Indent = 2";
|
|
ws.Cell(ro, co).Style.Alignment.Indent = 2;
|
|
|
|
ws.Cell(++ro, co).Value = "JustifyLastLine = true";
|
|
ws.Cell(ro, co).Style.Alignment.JustifyLastLine = true;
|
|
|
|
ws.Cell(++ro, co).Value = "ReadingOrder = ContextDependent";
|
|
ws.Cell(ro, co).Style.Alignment.ReadingOrder = XLAlignmentReadingOrderValues.ContextDependent;
|
|
|
|
ws.Cell(++ro, co).Value = "RelativeIndent = 2";
|
|
ws.Cell(ro, co).Style.Alignment.RelativeIndent = 2;
|
|
|
|
ws.Cell(++ro, co).Value = "ShrinkToFit = true";
|
|
ws.Cell(ro, co).Style.Alignment.ShrinkToFit = true;
|
|
|
|
ws.Cell(++ro, co).Value = "TextRotation = 45";
|
|
ws.Cell(ro, co).Style.Alignment.TextRotation = 45;
|
|
|
|
ws.Cell(++ro, co).Value = "TopToBottom = true";
|
|
ws.Cell(ro, co).Style.Alignment.TopToBottom = true;
|
|
|
|
ws.Cell(++ro, co).Value = "Vertical = Center";
|
|
ws.Cell(ro, co).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
|
|
|
ws.Cell(++ro, co).Value = "WrapText = true";
|
|
ws.Cell(ro, co).Style.Alignment.WrapText = true;
|
|
|
|
workbook.SaveAs(filePath);
|
|
}
|
|
|
|
// Private
|
|
|
|
// Override
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|