- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
public DataTable ConvertToString(Array values, int col_length, int row_length, int counter) {
DataTable dt = new DataTable();
string[] theArray = new string[col_length];
if (row_length < counter)
counter = row_length;
for (int j = 1; j <= counter; j++) {
for (int i = 1; i <= col_length; i++) {
if (j == 1) {
try {
dt.Columns.Add(values.GetValue(j, i).ToString().Replace('.', '_'));
} catch (NullReferenceException nre) {
dt.Columns.Add("F" + i);
}
} else if (values.GetValue(j, i) == null)
theArray[i - 1] = "";
else
theArray[i - 1] = (string)values.GetValue(j, i).ToString();
}
if (j != 1)
dt.LoadDataRow(theArray, true);
}
return dt;
}
Follow us!