Hi…
I will be getting filled form from client… I need to extract all fields and its values in form of key value pairs from the form… Kindly assist.
Thanks for your query.
I am not sure about your requirements. Could you provide more details and sample Excel file to demonstrate which field and its value you are talking about, we will check it soon.
In word and pdf we are able to find all fields and its values. I want to perform similar operation in excel
I think there is no similar field concept in MS Excel. We again request you to kindly do share a sample Excel file to demonstrate what you want to achieve, this will help us understand you and we may help you better.
AsposeRefExcelfinal.zip (12.1 KB)
Hi,
I have mentioned in excel itself how what key value i want. thanks
Thanks for the template file.
I have evaluated your scenario/case a bit using your sample file. Well, we can see common data only in the two columns. You think it is key-value pairs but for the data in Excel, there is not any difference when comparing with other data. I am afraid, we cannot know which column contains the key and which column contains values. Also, from your template file, there is not any condition that we can depend on to determine the start and end position of the key-value pairs either. There is no model which we can handle for it. Only you know the data structure of your file. So, you got to devise your own approach and method to evaluate and extract key value pairs in the sheet. You may use Hashtable or other objects to manually evaluate and save key- value pairs accordingly I am afraid, we cannot do that as we do not know which data are keys or which data are values and where to start from, etc., so you have to trace and keep them by yourself.
Here is a simple example on how we can extract and save key value pairs in HashTable
e.g
Sample code:
Workbook wb = new Workbook("e:\\test2\\AsposeRefExcelfinal.xlsx");
Hashtable hashTable = new Hashtable();
Cells cells = wb.Worksheets[0].Cells;
//Loop through a matrix (A2:A5).
//The first cell in the row would be taken as key
//and next cell (in that row) woulld be value.
//You would also need to devise the rule by yourself for key value pairs.
for (int i = 1; i < 5; i++)
{
Cell cellKey = cells[i,0];
Cell cellValue = cells[i,1];
hashTable.Add(cellKey.StringValue, cellValue.StringValue);
}
foreach (string key in hashTable.Keys)
{
Console.WriteLine(key.ToString());
}
Hope, this helps a bit.
cellname is key and value in that cell is value…
cant we extract that?
As I told you before you got to devise your own approach/method (manual) and logic to accomplish your task. For example, in the above code segment, you may simply loop through the cells in the sheet and use Cell.Name as key and Cell.StringValue/Value as value for the Hashtable.