Skip to content

Commit

Permalink
Adjust AppendObject to utilize NameAttribute from CsvHelper (#47)
Browse files Browse the repository at this point in the history
* add append object method so values can be imported correctly instead of just all being strings

* Adding method documentation for the new method created

* adjust AppendObject to utilize NameAttribute from CsvHelper

---------

Co-authored-by: SteveWinward <[email protected]>
  • Loading branch information
drgrieve and SteveWinward authored Oct 31, 2024
1 parent 0e5264b commit 0b38ad9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/GoogleSheetsWrapper/SheetAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ public void AppendObject<T>(IEnumerable<T> dataRecords, int batchWaitTime = 1000
};

foreach (var header in properties)
{
{
var name = header.Name;
var nameAttribute = header.GetCustomAttributes(typeof(CsvHelper.Configuration.Attributes.NameAttribute), true).FirstOrDefault();
if (nameAttribute != null)
{
name = (nameAttribute as CsvHelper.Configuration.Attributes.NameAttribute).Names.FirstOrDefault() ?? name;
}
row.Values.Add(StringToCellData(header.Name));
}

Expand Down

0 comments on commit 0b38ad9

Please sign in to comment.