VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "API_XLRecordsWrapper"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' ==== Оболочка для листа Excel как источника записей данных =========
' Shared module version: 20210329
' Depends on:
' Required reference:
' Prerequisites: first column should contain data with no empty cells
Option Explicit

Private data_ As Excel.Worksheet
Private row_ As Long
Private start_ As Long

Public Function Init(ws As Excel.Worksheet, Optional nStart& = 2)
  start_ = nStart
  Set data_ = ws
  Call MoveStart
End Function

Public Function MoveStart()
  row_ = start_
End Function

Public Function IsDone() As Boolean
  IsDone = data_.Cells(row_, 1) = vbNullString
End Function

Public Function MoveNext() As Boolean
  MoveNext = Not IsDone
  If MoveNext Then _
    row_ = row_ + 1
End Function

Public Function MovePrev() As Boolean
  MovePrev = row_ > start_
  If MovePrev Then _
    row_ = row_ - 1
End Function

Public Function Field(nColumn&) As Excel.Range
  Set Field = data_.Cells(row_, nColumn)
End Function
