Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GoogleSheetsWrapper/GoogleSheetsWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageProjectUrl>https://github.com/SteveWinward/GoogleSheetsWrapper</PackageProjectUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/SteveWinward/GoogleSheetsWrapper</RepositoryUrl>
<Version>2.0.26</Version>
<Version>2.0.27</Version>
<PackageTags>Google Sheets</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>A simple wrapper library that makes it easier to perform CRUD operations against Google Sheets spreadsheets.</Description>
Expand Down
30 changes: 15 additions & 15 deletions src/GoogleSheetsWrapper/SheetExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class SheetExporter
/// <summary>
/// Constructor
/// </summary>
/// <param name="spreadsheetID"></param>
/// <param name="serviceAccountEmail"></param>
/// <param name="tabName"></param>
/// <param name="spreadsheetID">The identifier of the spreadsheet to export.</param>
/// <param name="serviceAccountEmail">The service account email used for authentication.</param>
/// <param name="tabName">The tab to export.</param>
public SheetExporter(string spreadsheetID, string serviceAccountEmail, string tabName)
{
_sheetHelper = new SheetHelper(spreadsheetID, serviceAccountEmail, tabName);
Expand All @@ -29,16 +29,16 @@ public SheetExporter(string spreadsheetID, string serviceAccountEmail, string ta
/// <summary>
/// Constructor
/// </summary>
/// <param name="sheetHelper"></param>
/// <param name="sheetHelper">The initialized sheet helper to use for export operations.</param>
public SheetExporter(SheetHelper sheetHelper)
{
_sheetHelper = sheetHelper;
}

/// <summary>
///
/// Initializes the underlying sheet helper using service account credentials.
/// </summary>
/// <param name="jsonCredentials"></param>
/// <param name="jsonCredentials">Service account credentials in JSON format.</param>
public void Init(string jsonCredentials)
{
_sheetHelper.Init(jsonCredentials);
Expand All @@ -47,9 +47,9 @@ public void Init(string jsonCredentials)
/// <summary>
/// Exports the current Google Sheet tab to a CSV file
/// </summary>
/// <param name="range"></param>
/// <param name="stream"></param>
/// <param name="delimiter"></param>
/// <param name="range">The range to export.</param>
/// <param name="stream">The destination stream for the CSV content.</param>
/// <param name="delimiter">The delimiter used between CSV fields.</param>
public void ExportAsCsv(SheetRange range, Stream stream, string delimiter = ",")
{
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
Expand All @@ -63,9 +63,9 @@ public void ExportAsCsv(SheetRange range, Stream stream, string delimiter = ",")
/// <summary>
/// Exports the current Google Sheet tab to a CSV file. This override lets you explicitly specify the CsvConfiguration object for the CsvHelper library.
/// </summary>
/// <param name="range"></param>
/// <param name="stream"></param>
/// <param name="csvConfiguration"></param>
/// <param name="range">The range to export.</param>
/// <param name="stream">The destination stream for the CSV content.</param>
/// <param name="csvConfiguration">The CsvHelper settings used to generate the CSV content.</param>
public void ExportAsCsv(SheetRange range, Stream stream, CsvConfiguration csvConfiguration)
{
var rows = _sheetHelper.GetRowsFormatted(range);
Expand All @@ -84,10 +84,10 @@ public void ExportAsCsv(SheetRange range, Stream stream, CsvConfiguration csvCon
}

/// <summary>
/// Exports the current Google Sheet tab to a CSV file
/// Exports the specified Google Sheet range to an Excel workbook.
/// </summary>
/// <param name="range"></param>
/// <param name="stream"></param>
/// <param name="range">The range to export.</param>
/// <param name="stream">The destination stream for the Excel workbook.</param>
public void ExportAsExcel(SheetRange range, Stream stream)
{
var rows = _sheetHelper.GetRowsFormatted(range);
Expand Down
40 changes: 20 additions & 20 deletions src/GoogleSheetsWrapper/SheetFieldAttributeUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace GoogleSheetsWrapper
public class SheetFieldAttributeUtils
{
/// <summary>
///
/// Populates the attributed properties of a record from a row returned by Google Sheets.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="record"></param>
/// <param name="row"></param>
/// <param name="minColumnId"></param>
/// <typeparam name="T">The record type to populate.</typeparam>
/// <param name="record">The record instance to populate.</param>
/// <param name="row">The source row values.</param>
/// <param name="minColumnId">The one-based column index represented by the first value in <paramref name="row"/>.</param>
/// <exception cref="ArgumentException"></exception>
public static void PopulateRecord<T>(T record, IList<object> row, int minColumnId = 1) where T : BaseRecord
{
Expand Down Expand Up @@ -99,11 +99,11 @@ public static void PopulateRecord<T>(T record, IList<object> row, int minColumnI
/// <summary>
/// Converts the objects values to CellData object for Google Sheets API
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="record"></param>
/// <param name="attribute"></param>
/// <param name="property"></param>
/// <returns></returns>
/// <typeparam name="T">The record type containing the property.</typeparam>
/// <param name="record">The record that provides the property value.</param>
/// <param name="attribute">The sheet metadata that defines the cell format.</param>
/// <param name="property">The property to convert.</param>
/// <returns>A Google Sheets cell containing the property's value and formatting.</returns>
/// <exception cref="ArgumentException"></exception>
public static CellData GetCellDataForSheetField<T>(T record, SheetFieldAttribute attribute, PropertyInfo property)
{
Expand Down Expand Up @@ -238,11 +238,11 @@ public static CellData GetCellDataForSheetField<T>(T record, SheetFieldAttribute
}

/// <summary>
///
/// Gets the one-based sheet column index associated with a record property.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="expression"></param>
/// <returns></returns>
/// <typeparam name="T">The record type that declares the property.</typeparam>
/// <param name="expression">An expression that selects the attributed property.</param>
/// <returns>The property's configured column index.</returns>
public static int GetColumnId<T>(Expression<Func<T, object>> expression) where T : BaseRecord
{
var attribute = GetSheetFieldAttribute(expression);
Expand All @@ -251,20 +251,20 @@ public static int GetColumnId<T>(Expression<Func<T, object>> expression) where T
}

/// <summary>
///
/// Gets all sheet field metadata declared by a record type, ordered by column index.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
/// <typeparam name="T">The record type to inspect.</typeparam>
/// <returns>The sheet field attributes and their associated properties.</returns>
public static SortedDictionary<SheetFieldAttribute, PropertyInfo> GetAllSheetFieldAttributes<T>()
{
return GetAllSheetFieldAttributes(typeof(T));
}

/// <summary>
///
/// Gets all sheet field metadata declared by a type, ordered by column index.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
/// <param name="type">The type to inspect.</param>
/// <returns>The sheet field attributes and their associated properties.</returns>
public static SortedDictionary<SheetFieldAttribute, PropertyInfo> GetAllSheetFieldAttributes(Type type)
{
var result = new SortedDictionary<SheetFieldAttribute, PropertyInfo>(new SheetFieldAttributeComparer());
Expand Down
Loading
Loading