Skip to content

How do I set value to a cell in the dataset

This example demonstrates setting a value to a specific cell in a dataset.

In the solution shown below, a dataset is created using "ddCreateDataSet" command. A row is added to the dataset using "ddAddRows" command. The value is set into the required cell in two ways, one is by index using "ddSetCellValueByIndex" command and the other is by name using "ddSetCellValueByName" command. The dataset is persisted to the data file using "ddPersistDatasetToDataFile" command.

Solution:

Approach 1: Setting the required cell value by index

# Command Target Value
Creating the dataset and specifying the data definition name of the data file
1ddCreateDataSet InsuranceDetails
Insurance Details(W)
Adding a row to the dataset
2ddAddRows InsuranceDetails 1
Setting the value of a specific row by index
3ddSetCellValueByIndex
InsuranceDetails(0,0) 45
Persisting the dataset to a data file
4ddPersistDatasetToDataFileInsuranceDetailsInsurance Details(W)

Approach 2: Setting the required cell value by index

# Command Target Value
Creating the dataset and specifying the data definition name of the data file
1ddCreateDataset InsuranceDetails
Insurance Details(W)
Adding a row to the dataset
2ddAddRows InsuranceDetails 1
Setting the value of a specific row by name
3ddSetCellValueByName
InsuranceDetails(0,Age) 45
Persisting the dataset to a data file
4ddPersistDatasetToDataFileInsuranceDetailsInsurance Details(W)

Tips, Tricks, Gotcha's & Best Practices: 

  • You should use the same dataset name which is created by using "ddCreateDataSet" command in "ddSetCellValueByIndex" and "ddSetCellValueByName" commands.
  • You can optionally pass the status of the Data Definition and Data file along with their names in "ddCreateDataSet" and "ddPersistDatasetToDataFile" commands. Allowed values for status are 'W'(WIP) and 'A'(Active). If the status value is not passed, the status is assumed to be 'W'(WIP) for "ddCreateDataSet" command and 'A'(Active) for "ddPersistDatasetToDataFile" command.


Feedback and Knowledge Base