isbn100
isbn100

Reputation: 31

Export object to excel using C#

What is the best way to export objet to excel file in C# (.net framework 3.5)?

Thanks in advance!

Upvotes: 3

Views: 4149

Answers (3)

James Manning
James Manning

Reputation: 13579

I've used EPPlus to generate xlsx files (basically reports - SQL Reporting Services 2008 R2 still doesn't support it natively, just the older xls).

I've heard good things about NPOI, which is a .NET port of the Apache POI project

If you want to do it 'natively' and interop with a real instance of Excel, you can use the classes in Excel's Primary Interop Assembly - look in the microsoft.office.interop.excel namespace

A lot depends on what kind of objects you have already and what you want your intended output to be - if you can specify more of that, we can give a more specific answer.

Upvotes: 1

code4life
code4life

Reputation: 15794

If it's tabular data, you could generate HTML tables and let Excel open it up intuitively. Otherwise I'd recommend COM Interop.

Upvotes: 1

Dog Ears
Dog Ears

Reputation: 10015

In the past I've used the clipboard to save objects to multiple formats that can then be pasted into different applications including Excel or Word, tyring to find an example online I stumble across this:

http://support.microsoft.com/kb/306023

Looks Good!

Upvotes: 0

Related Questions