I am new to c# programming and would like to know how we can read data from an excel cell by cell. In the below code, I am getting an array of data from Column A of excel as pValue1= a;b;c;d%;e%;f%; Now, I want to push only the values with % at the end into a different array if the header of column A=ID. Also, I want to enclose each item in pValue1 with single quotes.
Input:
| ID | Name |
|---|---|
| a | roy |
| b | may |
| c | Jly |
| d% | nav |
| e% | nov |
| f% | lio |
Expected output: pValue1= 'a';'b';'c' pValue3= d%e%f%
try {
Utils.ExcelFile excelFile = new Utils.ExcelFile(excelFilename);
DataTable excelData = excelFile.GetDataFromExcel();
// Column headers
param1 = 0 < excelData.Columns.Count ? excelData.Columns[0].ColumnName :string.Empty;
param2 = 1 < excelData.Columns.Count ? excelData.Columns[1].ColumnName :string.Empty;
ArrayList pValueArray1 = new ArrayList();
ArrayList pValueArray2 = new ArrayList();
if (pValueArray1.Count > 0) pValue1 = string.Join(";", pValueArray1.ToArray()) + ";";
if (pValueArray2.Count > 0) pValue2 = string.Join(";", pValueArray2.ToArray()) + ";";
}