public void PopulateTheirDataList(FileInfo theirFileInfo) { // Validate input exists if (!theirFileInfo.Exists) { throw new ArgumentException( "The file name given to populate their data list doesn't exist.", "theirFileInfo", new Exception( string.Format("Given File for Their Data: {0}", theirFileInfo))); } using (var sl = new SLDocument(theirFileInfo.FullName)) { #if True var theirDataCells = sl.GetCells(); var sharedStrings = sl.GetSharedStrings(); // Gather the headers TheirHeaders.Clear(); var row = theirDataCells[1]; for (int i = 1; i <= row.Count; i++) { var cell = row[i]; TheirHeaders.Add( ConvertCellToString( cell, sharedStrings) .Trim() .ToUpper()); } TheirDataList.Clear(); // Data starts at row 2 for (int i = 2; i < theirDataCells.Count; i++) { TheirDataList.Add(ConvertCellsToTheirData(i, theirDataCells, sharedStrings)); } #else { var headerIndex = 1; var row = 2; var col = 1; var value = sl.GetCellValueAsString(1, headerIndex); var header = new List <string>(); var lineElements = new List <string>(); // Gather all the headers while (!string.IsNullOrWhiteSpace(value)) { header.Add(value.Trim().ToUpper()); value = sl.GetCellValueAsString(1, ++headerIndex); } TheirHeaders = new List <string>(header); // Get the format handler setup var dataReaderFormatHandler = new ClickAndImpressionFormatHandler(); // Add the Null Format Handler to tell us we can't process this file dataReaderFormatHandler.SetSuccessor(new NullFormatHandler()); while (!string.IsNullOrWhiteSpace(sl.GetCellValueAsString(row, 1))) { while (col < headerIndex) { lineElements.Add(sl.GetCellValueAsString(row, col).Trim()); col++; } TheirDataList.Add(dataReaderFormatHandler.ReadLine(lineElements)); // Setup for next loop row++; col = 1; lineElements.Clear(); } } #endif } }
public void ClearTheirDataList() { TheirDataList.Clear(); }