Skip to content

Commit

Permalink
#1058, #946 added hyperlink style to hyperlinks created by the LoadFr…
Browse files Browse the repository at this point in the history
…omCollection method
  • Loading branch information
swmal authored and swmal committed Sep 29, 2023
1 parent b3ae72c commit cc0106f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/EPPlus/ExcelWorksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3499,7 +3499,7 @@ private void SetValuesWithHyperLink(int fromRow, int fromColumn, object[,] value
var t = v.GetType();
if (t == typeof(Uri) || t == typeof(ExcelHyperLink))
{
if (!hyperlinkStylesAdded)
if (!hyperlinkStylesAdded && addHyperlinkStyles)
{
if (!Workbook.Styles.NamedStyles.ExistsKey("Hyperlink"))
{
Expand All @@ -3508,11 +3508,6 @@ private void SetValuesWithHyperLink(int fromRow, int fromColumn, object[,] value
hls.Style.Font.UnderLine = true;
hls.Style.Font.Color.SetColor(System.Drawing.Color.FromArgb(0x0563C1));
}
//if (!Workbook.Styles.NamedStyles.ExistsKey("Followed Hyperlink"))
//{
// var fhls = Workbook.Styles.CreateNamedStyle("Followed Hyperlink");
// fhls.BuildInId = 9;
//}
hyperlinkStylesAdded = true;
}
Cells[row, col].StyleName = "Hyperlink";
Expand Down
6 changes: 3 additions & 3 deletions src/EPPlusTest/LoadFunctions/LoadFromCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace EPPlusTest.LoadFunctions
[TestClass]
public class LoadFromCollectionTests : TestBase
{
[EpplusTable(AutofitColumns = true, PrintHeaders = true, TableStyle = TableStyles.Dark1)]
[EpplusTable(AutofitColumns = true, PrintHeaders = true, TableStyle = TableStyles.Light10)]
internal class Company
{
public Company(int id, string name, Uri url)
Expand Down Expand Up @@ -555,12 +555,12 @@ public void LoadListOfClassWithEnumWithDescription()
public void LoadWithAttributesTest()
{
var l = new List<Company>();
l.Add(new Company(1, "EPPlus Softeware AB", new Uri("https://epplussoftware.com")));
l.Add(new Company(1, "EPPlus Software AB", new Uri("https://epplussoftware.com")));

using (var package = OpenPackage("LoadFromCollectionAttr.xlsx", true))
{
var sheet = package.Workbook.Worksheets.Add("test");
sheet.Cells["A1"].LoadFromCollection(l);
sheet.Cells["A1"].LoadFromCollection(l, x => x.UseBuiltInStylesForHyperlinks = true);

SaveAndCleanup(package);
}
Expand Down

0 comments on commit cc0106f

Please sign in to comment.