static void AddToValidations(ICollection <DataValidation> validations, HSSFSheet sheet, string[] names) { InternalSheet internalSheet = sheet.Sheet; var dataValidityTable = (DataValidityTable)internalSheet.GetType() .GetField("_dataValidityTable", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(internalSheet); if (dataValidityTable == null) { return; } var validationList = (IList)dataValidityTable.GetType() .GetField("_validationList", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(dataValidityTable); foreach (DVRecord record in validationList) { var formula = (Formula)record.GetType() .GetField("_formula1", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(record); var validation = new DataValidation { Range = ExcelHelper.ParseRange(record.CellRangeAddress.CellRangeAddresses[0].FormatAsString(), ExcelVersion.Xls) }; Ptg ptg = formula.Tokens[0]; var namePtg = ptg as NamePtg; if (namePtg != null) { validation.Type = DataValidationType.Formula; validation.Name = names.ElementAt(namePtg.Index); } else { var stringPtg = ptg as StringPtg; if (stringPtg != null) { validation.Type = DataValidationType.List; validation.List = stringPtg.Value.Split('\0'); } else { continue; } } validations.Add(validation); } }