Research reported by ACE (American Council on Exercise) has shown that in fact, the opposite can happen. When we consume these high-sugar foods, our body works hard to bring our blood-sugar levels back down to normal, and can in fact remove some necessary sugars for our workout. We get what is called a "rebound effect" which is when our sugar levels drop lower than intended. We are then left feeling drained and not as energized as we wanted for our workout.
Instead, many advise that people consume foods higher in carbohydrates 2-3 hours before a workout. This way, the body has time to accommodate the food and can use the carbohydrates as energy for the workout, instead of a sudden onset of sugar that acts as a "shock" to the body.
So instead of that candy bar right before a workout, grab a bagel and some yogurt or fruit a few hours before hand to give you the sustainable energy that you're looking for.