3

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

Thanks in advance!

3
  • 1
    What kind of object? Is it a collection of things or whatnot? Commented Jun 6, 2010 at 21:24
  • It's a complicated object (conatins amongst other, lists etc'), but what i have to do is to process the data in the object and export it to excel sheet. can you help? Commented Jun 6, 2010 at 21:32
  • what format of Excel file? xls? xlsx? csv? or anything as long as Excel can open it? And if the latter, which version(s) of Excel? Commented Jun 7, 2010 at 0:43

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.