Shares of office supply company Staples (NASDAQ:SPLS) surged after the company on Nov. 19 beat analyst estimates for quarterly earnings, posting strong growth in both its commercial and online businesses. Staples' investments in the past couple of years appear to be paying off, and some management comments during the company's conference call provide a deeper look into Staples' turnaround efforts.

All sales aren't lost when stores are closed

"During the third quarter we closed 31 stores [in] North America, bringing our year-to-date store closures to 127. Sales transfer from these stores has come in ahead of our expectations. Over the past few weeks we've also seen an acceleration in the pace of competitor store closures and our share gains from these stores have also been a little ahead of our expectations."
-- CEO Ron Sargent

Staples has closed 127 stores to date in 2014, with plans to raise that number to 170 by the end of the year. Closing stores reduces revenue, of course, but not all the sales are lost. A fraction of revenue from closed stores transfers to remaining locations, and this amount has so far been higher than Staples initially expected.

Staples also gains a fraction of revenue from stores closed by competitor Office Depot, and these gains have also been above expectations.

These sales transfers are important because they raise the profitability of the remaining stores, increasing revenue without a concurrent increase in fixed costs. While losing some revenue seems like a bad result, keeping the retail stores profitable is far more important.

Not just office supplies anymore

"Sales in categories beyond office supplies now represent more than 40% of our mix in North American commercial or about $3.5 billion annually. These new categories will become the growth engine for our company and we plan to build on our momentum here."
-- Sargent

Part of Staples' long-term plan is shifting from a company that sells mainly core office supplies, like paper products, to one which sells everything a business needs. Staples has greatly expanded the assortment of products that it sells to its commercial customers, which has helped the North American commercial segment stand as the strongest part of Staples' business.

The North American commercial segment grew by 3.3% during the most recent quarter, an acceleration from the previous quarter. While demand for core office supplies remains weak, Staples has managed to grow sales of other categories enough to make up for this weakness. Noncore office supplies now make up 40% of the commercial business, and this number will likely continue to grow. Staples is no longer just an office supply company.

The online business is improving

"[] Traffic was up double digits, customer conversion more than doubled and our online back-to-school center drove an improved customer experience during this important time of the year."
-- Sargent is Staples' consumer- and small business-oriented website, and its growth has accelerated. Sales grew by 9% during the most recent quarter, and it now represents about 21% of the company's North American retail and online segment. A strong e-commerce business will prove critical as more spending moves online, and Staples is positioning itself to benefit from that trend.

Staples redesigned its website late last year, and the company has been investing in technology in order to compete against other online retailers. This has led to robust traffic growth and big improvements in converting website visitors. An aggressive rewards program, which offers free shipping on every order, along with other perks, has also likely been a factor.

The retail stores are more profitable than they appear

"From a channel perspective, the investments we're making to accelerate growth online have weight on the bottom line. If you look at our operating margin rate for it was in the low single digits during Q3 and in retail we achieved an operating margin rate of approximately 10% in the third quarter."
-- Sargent

There is a downside to rapid online sales growth. Margins online are far lower than in retail stores, partly because of the investments Staples has made over the past couple of years. This has the effect of dragging down margins for the retail segment, obscuring the profitability of Staples' stores.

Staples' retail stores managed an operating margin of roughly 10% during the third quarter, an impressive result for any retailer, let alone an office supply retailer. was far less profitable, with an operating margin in the low single-digits, and strong online growth was one reason why the retail segment's operating margin declined year over year in the third quarter.

Sargent said the focus for 2015 would be improving profitability in the e-commerce business, now that the bulk of the company's necessary investments are complete. This should give margins in the retail segment a boost, offsetting the negative effect of declining comparable-store sales.

 Staples still generates plenty of cash

"[W]e now expect to generate more than $800 million of free cash flow in 2014 versus our previous free cash flow guidance of more than $600 million."
-- CFO Christine Komola

Thanks to Staples' strong performance, along with the timing of certain restructuring payments, the company now expects to generate more than $800 million in free cash flow this year. That's more than the $737 million Staples generated last year, and while it's below peak values from a few years ago, it's still more than enough to cover Staples' dividend and share buyback programs.

Staples paid out $308 million in dividend payments during the past 12 months, and spent $220 million on share buybacks. Staples hasn't raised its dividend since the beginning of 2013, but an increase could be in the cards given the low payout ratio relative to free cash flow. Staples reduced total debt from $2.5 billion at the beginning of 2010 to just $1.1 billion today. Given the stronger balance sheet and the ample free cash flow, an increase in the amount of capital returned to shareholders is a real possibility.

Timothy Green owns shares of Staples. The Motley Fool owns shares of Staples. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.