Skip to content

Commit 0b38ad9

Browse files
Adjust AppendObject to utilize NameAttribute from CsvHelper (#47)
* 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 <2002602+SteveWinward@users.noreply.github.com>
1 parent 0e5264b commit 0b38ad9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/GoogleSheetsWrapper/SheetAppender.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ public void AppendObject<T>(IEnumerable<T> dataRecords, int batchWaitTime = 1000
187187
};
188188

189189
foreach (var header in properties)
190-
{
190+
{
191+
var name = header.Name;
192+
var nameAttribute = header.GetCustomAttributes(typeof(CsvHelper.Configuration.Attributes.NameAttribute), true).FirstOrDefault();
193+
if (nameAttribute != null)
194+
{
195+
name = (nameAttribute as CsvHelper.Configuration.Attributes.NameAttribute).Names.FirstOrDefault() ?? name;
196+
}
191197
row.Values.Add(StringToCellData(header.Name));
192198
}
193199

0 commit comments

Comments
 (0)