Sweden State Railways - SJ - operate the intercity trains and include journeys to Copenhagen and Oslo amongst their scheduled journeys. There are also train links in the north of Sweden to Norway (Narvik) and Finland (Kemi). To plan a journey, consult their website. Booking in advance can save you a lot of money on train travel and spontaneity will get you nowhere –jumping on a train and buying a ticket on board will incur a surcharge – see more details in the domestic travel section here.
Unfortunately it is not easy to take bikes on Swedish railways – they need to be booked in advance and boxed up to go in to the luggage carriages. So grabbing the bikes and heading off for the weekend takes a bit of planning!
From Copenhagen, links into the rest of Europe are easy through Germany and a night sleeper train operates from Malmö to Berlin. SJ recommend you consult the German state railway's website to plan longer European journeys.