Create a Unique ID in a column in Excel

Hello @shikharno.7

Read existing data into DataTable
DataTable dt = ReadDataFromSource();

Find the maximum existing ID
int maxExistingID = dt.AsEnumerable().Max(row => Convert.ToInt32(row[“ID”]));

Generate and add new rows with unique IDs
for each newDataRow in NewDataToAdd
{
maxExistingID++; // Increment the maximum ID
DataRow newRow = dt.NewRow();
newRow[“ID”] = maxExistingID;
Set other values for the new row
Add the newRow to the DataTable
dt.Rows.Add(newRow);
}

Thanks & Cheers!!!