public IEnumerable<IList<CellData>> Rows()
{
if (!File.Exists(_filePath))
throw new FileNotFoundException(_filePath + " file not found.");
var connectionString = getConnectionString();
using (var oleDbConnection = new OleDbConnection(connectionString))
{
using (var oleDbCommand = new OleDbCommand(_sql, oleDbConnection) { CommandTimeout = 1200 })
{
SqlParametersParser.ApplySafeParameters(oleDbCommand, _sql, _paramValues);
oleDbCommand.Connection.Open();
using (var oleDbReader = oleDbCommand.ExecuteReader())
{
while (oleDbReader != null && oleDbReader.Read())
{
var result = new List<CellData>();
for (var i = 0; i < oleDbReader.FieldCount; i++)
{
var value = oleDbReader.GetValue(i);
var pdfCellData = new CellData
{
PropertyName = oleDbReader.GetName(i),
PropertyValue = (value == DBNull.Value) ? null : value,
PropertyIndex = i
};
result.Add(pdfCellData);
}
yield return result;
}
}
}
}
}