Class GoogleSheetReader


public class GoogleSheetReader extends AbstractReader
Reads records from one sheet, or one range, of a Google Sheets spreadsheet opened as a GoogleSheetDocument; the sheet is the one the range names, else the named sheet, else the sheet at the index. Rows are loaded when the reader opens.
  • Constructor Details

  • Method Details

    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class AbstractReader
      Throws:
      DataException
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class DataEndpoint
      Throws:
      DataException
    • getDocument

      public GoogleSheetDocument getDocument()
    • setAutoCloseDocument

      public GoogleSheetReader setAutoCloseDocument(boolean autoCloseDocument)
      Indicates if the GoogleSheetDocument should be closed when this endpoint is closed. The default is false.
    • isAutoCloseDocument

      public boolean isAutoCloseDocument()
      Indicates if the GoogleSheetDocument should be closed when this endpoint is closed. The default is false.
    • getSheetName

      public String getSheetName()
    • setSheetName

      public GoogleSheetReader setSheetName(String sheetName)
      Sets the name of the sheet to read; when set, it is used instead of the sheet index (default is null).
    • getRange

      public String getRange()
    • setRange

      public GoogleSheetReader setRange(String range)
      Sets the A1-notation range to read, such as A1:B3 or Sheet1!A1:B3; a range without a sheet prefix is read from the sheet named or indexed on this reader (default is null for the whole sheet).
    • getSheetIndex

      public int getSheetIndex()
    • setSheetIndex

      public GoogleSheetReader setSheetIndex(int sheetIndex)
      Sets the 0-based index of the sheet to read when no sheet name or range names one (defaults to 0).
    • getStartingColumn

      public int getStartingColumn()
    • setStartingColumn

      public GoogleSheetReader setStartingColumn(int startingColumn)
      Sets the 0-based index of the first column read; earlier columns are skipped (defaults to 0).
    • getLineNumber

      public long getLineNumber()
      Returns the 0-based index of the next row to read within the loaded sheet or range.
    • setFieldNamesInFirstRow

      public GoogleSheetReader setFieldNamesInFirstRow(boolean fieldNamesInFirstRow)
      Description copied from class: AbstractReader
      Indicates if the first row holds the field names instead of data (default is false); must be called before AbstractReader.open().
      Overrides:
      setFieldNamesInFirstRow in class AbstractReader
    • setFieldNames

      public GoogleSheetReader setFieldNames(String... fieldNames)
      Description copied from class: AbstractReader
      Sets the names given to each record's fields, taking precedence over names in the first row; must be called before AbstractReader.open().
      Overrides:
      setFieldNames in class AbstractReader
    • setFieldNames

      public GoogleSheetReader setFieldNames(Collection<String> fieldNames)
      Description copied from class: AbstractReader
      Sets the names given to each record's fields, taking precedence over names in the first row; must be called before AbstractReader.open().
      Overrides:
      setFieldNames in class AbstractReader
    • setStartingRow

      public GoogleSheetReader setStartingRow(int startingRow)
      Description copied from class: AbstractReader
      Sets the 0-based index of the first row to read; earlier rows are skipped when the reader is opened (default is 0).
      Overrides:
      setStartingRow in class AbstractReader
    • setLastRow

      public GoogleSheetReader setLastRow(int lastRow)
      Description copied from class: AbstractReader
      Sets the 0-based index of the last row to read or -1 to read to the end (default is -1).
      Overrides:
      setLastRow in class AbstractReader
    • setSkipEmptyRows

      public GoogleSheetReader setSkipEmptyRows(boolean skipEmptyRows)
      Description copied from class: AbstractReader
      Indicates that rows with only null values should not be returned by the reader (default is false).
      Overrides:
      setSkipEmptyRows in class AbstractReader
    • setDescription

      public GoogleSheetReader setDescription(String description)
      Description copied from class: Endpoint
      Sets the optional text shown for this endpoint in Endpoint.toString() and exception properties.
      Overrides:
      setDescription in class Endpoint
    • fillRecord

      protected boolean fillRecord(Record record) throws Throwable
      Description copied from class: AbstractReader
      Populates the given record with the next row's values; returns false at the end of the input.
      Specified by:
      fillRecord in class AbstractReader
      Throws:
      Throwable
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class AbstractReader