Anita International has created a software (Tally Barcoder) which can be used in combination with Tally ERP9 to do exactly what you were asking for. Please note that when you install the software and the first time you're starting it, a pop-up prompt appears asking you for the path of Tally ERP9 software. If you don't have Tally installed you can try Excel mode but first when you log in, a password field will be prompted and all you have to do is to enter admin
then configure it for your own needs. You can even print in demo mode and preview the results in a different window.