Trex posts sales and earnings gains