Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Commit

Permalink
Incremented version (v2.2.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
eraydin committed Jun 5, 2018
1 parent 6a33463 commit cd6c82c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.2.0</VersionPrefix>
<VersionPrefix>2.2.1</VersionPrefix>
<Description>An extensions library for both EPPlus and EPPlus.Core packages to generate and manipulate Excel files easily.</Description>

<NoWarn>$(NoWarn);CS1591</NoWarn>
Expand Down
4 changes: 2 additions & 2 deletions src/EPPlus.Core.Extensions/ExcelPackageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static DataSet ToDataSet(this ExcelPackage package, bool hasHeaderRow = t
}

/// <summary>
/// Converts given worksheet into list of objects as enumerable
/// Converts given package into list of objects as enumerable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="package"></param>
Expand All @@ -76,7 +76,7 @@ public static DataSet ToDataSet(this ExcelPackage package, bool hasHeaderRow = t
public static IEnumerable<T> AsEnumerable<T>(this ExcelPackage package, int worksheetIndex = 1, Action<ExcelReadConfiguration<T>> configurationAction = null) where T : class, new() => package.GetWorksheet(worksheetIndex).AsEnumerable(configurationAction);

/// <summary>
/// Converts given worksheet into list of objects
/// Converts given package into list of objects
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="package"></param>
Expand Down
15 changes: 15 additions & 0 deletions src/EPPlus.Core.Extensions/ExcelTemplateGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@ namespace EPPlus.Core.Extensions
{
public static class ExcelTemplateGenerator
{
/// <summary>
/// Finds given type name in the assembly, and generates Excel package
/// </summary>
/// <param name="executingAssembly"></param>
/// <param name="typeName"></param>
/// <param name="action"></param>
/// <returns></returns>
public static ExcelPackage GenerateExcelPackage(this Assembly executingAssembly, string typeName, Action<ExcelRange> action = null)
{
var excelPackage = new ExcelPackage();
excelPackage.GenerateWorksheet(executingAssembly, typeName, action);
return excelPackage;
}

/// <summary>
/// Finds given type name in the assembly, and generates Excel worksheet
/// </summary>
/// <param name="excelPackage"></param>
/// <param name="executingAssembly"></param>
/// <param name="typeName"></param>
/// <param name="action"></param>
/// <returns></returns>
public static ExcelWorksheet GenerateWorksheet(this ExcelPackage excelPackage, Assembly executingAssembly, string typeName, Action<ExcelRange> action = null)
{
Type type = executingAssembly.GetExcelWorksheetMarkedTypeByName(typeName);
Expand Down
4 changes: 2 additions & 2 deletions src/EPPlus.Core.Extensions/Style/ExcelColumnExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static ExcelColumn SetFont(this ExcelColumn column, Font font)
}

/// <summary>
/// Sets the font color of ExcelColumn from a Color object
/// Sets the font color of ExcelColumn
/// </summary>
/// <param name="column"></param>
/// <param name="fontColor"></param>
Expand All @@ -30,7 +30,7 @@ public static ExcelColumn SetFontColor(this ExcelColumn column, Color fontColor)
column.Style.SetFontColor(fontColor);
return column;
}

/// <summary>
/// Sets the background color of ExcelColumn from a Color object
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/EPPlus.Core.Extensions/Style/ExcelRangeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public static ExcelRangeBase SetFontName(this ExcelRangeBase range, string newFo
return range;
}

public static ExcelRangeBase SetFontAsBold(this ExcelRangeBase range)
{
range.Style.SetFontAsBold();
return range;
}

/// <summary>
/// Sets the horizontal alignment of given range
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/EPPlus.Core.Extensions/Style/ExcelStyleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ public static ExcelStyle SetFontName(this ExcelStyle thisStyle, string newFontNa
return thisStyle;
}

public static ExcelStyle SetFontAsBold(this ExcelStyle thisStyle)
{
thisStyle.Font.Bold = true;
return thisStyle;
}

/// <summary>
/// Sets horizontal alignment of Excel style
/// </summary>
Expand Down
8 changes: 1 addition & 7 deletions src/EPPlus.Core.Extensions/WorksheetWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal List<WorksheetColumn<T>> AutoGenerateColumns()
List<ExcelTableColumnAttributeAndProperyInfo> properyInfoAndColumnAttributes = typeof(T).GetExcelTableColumnAttributesWithProperyInfo();

foreach (ExcelTableColumnAttributeAndProperyInfo properyInfoAndColumnAttribute in properyInfoAndColumnAttributes)
{
{
columns.Add(new WorksheetColumn<T>
{
Header = properyInfoAndColumnAttribute.ToString(),
Expand Down Expand Up @@ -127,12 +127,6 @@ internal void AppendWorksheet()
}
}

/// <summary>
/// Generates a Func from a propertyName
/// </summary>
/// <typeparam name="TP"></typeparam>
/// <param name="propertyName"></param>
/// <returns></returns>
private Func<TP, object> GetGetter<TP>(string propertyName)
{
ParameterExpression arg = Expression.Parameter(typeof(TP), "x");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public void Should_generate_an_worksheet_from_given_ExcelExportable_class_name()
// Act
//-----------------------------------------------------------------------------------------------------------
ExcelWorksheet worksheet1 = excelPackage.GenerateWorksheet(executingAssembly, wrongCarsType.Name);
ExcelWorksheet worksheet2 = excelPackage.GenerateWorksheet(executingAssembly, defaultMapType.Key, act => act.SetHorizontalAlignment(ExcelHorizontalAlignment.Right));
ExcelWorksheet worksheet2 = excelPackage.GenerateWorksheet(executingAssembly, defaultMapType.Key,
act => act.SetHorizontalAlignment(ExcelHorizontalAlignment.Right)
.SetFontAsBold());

//-----------------------------------------------------------------------------------------------------------
// Assert
Expand All @@ -70,6 +72,7 @@ public void Should_generate_an_worksheet_from_given_ExcelExportable_class_name()
worksheet2.Name.Should().Be("DefaultMap");
worksheet2.GetColumns(1).Count().Should().BeGreaterThan(0);
worksheet2.Cells[1, 1].Style.HorizontalAlignment.Should().Be(ExcelHorizontalAlignment.Right);
worksheet2.Cells[1, 2].Style.Font.Bold.Should().BeTrue();
}
}
}

0 comments on commit cd6c82c

Please sign in to comment.