Drag the Application or the File you want to pin into the task bar. It will get automatically pinned.
When you pin several files of the same application like several Excel sheets, only one Excel short cut will be available in the Task Bar. Right click it to See all the files you have pinned.