can you tell me the where i can get code for loging data either in excel sheet or text file
The arduino cannot write into an excel sheet.
Excel software runs on a computer, not an arduino.
Arduinos can send data using conventional serial protocol to other devices, including computers.
As far as I know, excel has no method available to collect this data itself.
You would need to write a program to run on your computer, to collect the serial data being sent by
the arduino, and then put that data into excel, or write it into a file which excel can read.