Many people look for friendships in the office because it is the most obvious place for them to meet others. You spend the majority of your waking hours during the week at work. And a lot of people are not involved in activities outside of work so it is the only place they really get to meet others.
In every office there are people you want to be friends with and there are those you do not. It can be complicated when someone in the office wants to be your friend and you do not want to be their friend. You do not want to hurt their feelings or be mean to them because that could make things awkward around the office, but you really dread the idea of hanging out with them outside of work or of them coming to your office to chat.
There are ways to go about letting a coworker know you are not interested in being their friend without causing friction or weirdness. Depending on the coworker it can be easy or hard to get across the message that you do not want to be friends. Some people will pick up on subtle hints such as you not ever agreeing to hang out with them outside of the office or turning down their requests to have lunch together. But there are people who do not pick up on the hints, or choose to ignore them. With these coworkers you might have to be a bit more upfront.
Be polite to your coworker, because you do have to work with this person. You do not want to create a hostile environment. The first thing to try is the subtle hints, turn down their invitations to hang out, have lunch together, etc... Do not engage in long conversations with them, because this could lead them on and make them think you do want to be friends after all. Limit your conversations to strictly work topics. Do not tell them personal details about yourself. If after a month or two your coworker has still not gotten the hint that you do not want to be their friend you might need to have a talk. Luckily, most people get it eventually and you do not have to have a talk.
For those coworkers who are clueless and persistant a talk might have to happen. Inform your coworker that you appreciate that they invite you out and that you are grateful for the invitations but your schedule is very busy and you have already commited to other things and people and just do not have the time. Try to avoid telling them bluntly that you do not like them and do not want to be their friend, because this is a coworker, someone that you one day might have to work closely with. Avoid being rude and hurting their feelings. You never know, that person might one day be your boss.