Easy Export to Excel with C#

Easy Export to Excel with C#

imageUsing a class provided by Chris on stackoverlow, I finally found a quick and dirty way to download data to a CSV file locally.

By adding the attached class file, I was able to easily add a button to a report page, that when pressed, will load the each line of the CsvExport object into a byte[] suitable for quick and dirty downloads.

The code looks something like this:

Obviously you would modify the lines following myExport.AddRow(); lines to reflect the columns of data that you want to include in the spreadsheet.

 

Anyone else have code they prefer to use for this purpose? Use the comments below to share will all of us and thanks again to Chris and stackoverflow!

csvexport.cs (3.43 kb)

Stalk Me...

Michael Gibbs

I'm a technologist at heart, assisting companies best utilize the Internet to market themselves and sell their products and services online. This includes organizations as large as Google and as small as one or two individuals.
At Over The Top and Exhibit A Communications, I've programmed solutions for Google as well as at least one other company that was later acquired by Google.

I've been CTO of an Internet SaaS company and spent my time pretty evenly between guiding the future technical strategy of the company, architecting software solutions for my dev teams, designing and running a data center to service our clients world-wide as well as being a technical evangalist/sales engineer to our media clients large and small.

I've also been Chief Photographer of the Daily Sun/Post newspaper back when it was a 5-day a week daily newspaper.

I also spent a great many years as a beach lifeguardfor the City of San Clemente as well as Jr. Lifeguard instructor and then as it's program coordinator.
Bragging rights
Private Pilot with Instrument rating and proud husband of soon to be 25 years (and counting).
Stalk Me...

Latest posts by Michael Gibbs (see all)

Leave a Reply