I am attaching the numbers in the excel sheet with each row. Based on the worksheet I want the output to come as the number to be separated with comma in one line.
For that amount of cells I can only think of a VBA based solution.
Attached is a subroutine that places the result in "B1".
A similar solution would be a UDF (user defined function). This would allow you to use it as a regular function.
By the way, the reverse can be done using the handy "Text to Columns" Excel tool:
1) Select the cell with the comma separated values and click "Text to Columns"... select "Delimited" and "next"
2) Set the delimiter as a comma and "next"
3) Leave everything as it is and finish:
4) After the previous steps you should have a row with each value in a different cell starting in "B1". Simply copy the entire range and "PasteSpecial" in "B2" selecting transpose: