I have a spreadsheet (roughly 200x200 in size) that is a matrix of 0's and 1's that define rules. These rules cannot be expressed in procedural logic because they need to be easily accessible for change by a user for modification.

The first row are header value strings and the values in the first column of each row are key strings for that row. What I need to be able to do is pull back the 0 or 1 value for a cell identified by a particular column string and header string value.

This needs to be done using VS2005, the application is a desktop forms app. I can easily pull the sheet into a DataSet but if there is a way to use the first row and first column string values as indices I am unfamiliar with it.

I am considering setting up enums for the strings and using their numeric values to index the locations in either the DataSet or an array, but would prefer to not have to do that to avoid having to change the code if additional rows or columns are added in the future.

I am thinking that my best bet is translating it into a new Table with columns for the Header and Key strings and a boolean column for the rule value.

Performance is a consideration, so I'd appreciate community input before I go down any particular course of implementation that I have mentioned or in case there is some amazingly superior approach that has not even occurred to me :-p


I attempted the the DataTable approach but it was far too slow. I ended up using a HashTable with the row/column strings concatenated with a ":" between and it appears instantaeous.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.