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.
74 lines
1.5 KiB
C#
74 lines
1.5 KiB
C#
using System;
|
|
using ClosedXML.Excel;
|
|
|
|
|
|
namespace ClosedXML_Examples
|
|
{
|
|
public class RowCells : IXLExample
|
|
{
|
|
#region Variables
|
|
|
|
// Public
|
|
|
|
// Private
|
|
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
// Public
|
|
|
|
// Private
|
|
|
|
// Override
|
|
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
// Public
|
|
|
|
// Private
|
|
|
|
// Override
|
|
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
// Public
|
|
public void Create(String filePath)
|
|
{
|
|
var workbook = new XLWorkbook();
|
|
var ws = workbook.Worksheets.Add("Row Cells");
|
|
|
|
var rowFromWorksheet = ws.Row(1);
|
|
rowFromWorksheet.Cell(1).Style.Fill.BackgroundColor = XLColor.Red;
|
|
rowFromWorksheet.Cells("2").Style.Fill.BackgroundColor = XLColor.Blue;
|
|
rowFromWorksheet.Cells("3,5:6").Style.Fill.BackgroundColor = XLColor.Red;
|
|
rowFromWorksheet.Cells(8, 9).Style.Fill.BackgroundColor = XLColor.Blue;
|
|
|
|
var rowFromRange = ws.Range("A2:I2").FirstRow();
|
|
|
|
rowFromRange.Cell(1).Style.Fill.BackgroundColor = XLColor.Red;
|
|
rowFromRange.Cells("2").Style.Fill.BackgroundColor = XLColor.Blue;
|
|
rowFromRange.Cells("3,5:6").Style.Fill.BackgroundColor = XLColor.Red;
|
|
rowFromRange.Cells(8, 9).Style.Fill.BackgroundColor = XLColor.Blue;
|
|
|
|
ws.Columns().Width = 7;
|
|
|
|
workbook.SaveAs(filePath);
|
|
}
|
|
|
|
// Private
|
|
|
|
// Override
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|