I think that the exercise before a hiking trip is good. However, in my experience, I found out the hard way that it isn't enough.
In 2008, my "trainer" at the YMCA gave me an exercise routine that would be good for hiking, she said. It involved a number of things and the big ones were fast walking laps around the gym track with two fast up and down a story flights of stairs for each lap. And 16 laps made a mile.
The other was an elliptical machine being used to simulate hiking with pole motions.
It didn't do the job, even about 3 months of it.
In 2009, I did up to 1 hour on the inclined treadmill (plus other stuff) at maximum inclination (15) and I included wearing a 21 pound backpack load (1 pound backpack and 20 pounds metal weights).
This helped quite a bit, but I became aware that there were lots more leg and body muscles used on the rocky and uneven hilly trail than the smooth unbumpy treadmill.
The thing that hit me was the best conditioning for hiking is probably hiking. It actually exercises the real muscles that your hiking trip will need to use.
I live in the flats of the Midwest, and preparing for mountains to hike with just a few small hills doesn't really seem possible. However, hiking the valley slopes of the Mississippi river valley would be better than nothing.
The exercise in the gym helps, but the exercise of preliminary local hiking would be even better. Probably kind of boring to go up and down the same 100 to 300 foot hills, but it would be better than nothing at all.
Flat.