Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using C# to read/write Excel files (.xls/.xlsx)

Tags:

How can I read and write Excel files in C#? I've already added the Excel Objects Library to my project, but I'm not getting a clear enough description of what needs to be done to access the files.

Please help me understand and, when explaining, please keep in mind I'm kind of new to this but I'm not a complete newbie. I study a lot, so I'm not totally ignorant.

like image 264
jitsuin Avatar asked May 02 '12 17:05

jitsuin


People also ask

What is C in used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

How do I use C on my computer?

This means that once you write your C program, you must run it through a C compiler to turn your program into an executable that the computer can run (execute). The C program is the human-readable form, while the executable that comes out of the compiler is the machine-readable and executable form.

Why do people use C?

C is mostly used in creating popular compilers . Many programming language compilers are developed with reference from C. This is due to the association of C to low-level programming languages. This eases the language to be comprehensible to machines.

Is C still useful?

The C programming language has been alive and kicking since 1972, and it still reigns as one of the fundamental building blocks of our software-studded world.


2 Answers

I'm a big fan of using EPPlus to perform these types of actions. EPPlus is a library you can reference in your project and easily create/modify spreadsheets on a server. I use it for any project that requires an export function.

Here's a nice blog entry that shows how to use the library, though the library itself should come with some samples that explain how to use it.

Third party libraries are a lot easier to use than Microsoft COM objects, in my opinion. I would suggest giving it a try.

like image 89
Brad Butner Avatar answered Oct 16 '22 11:10

Brad Butner


I use NPOI for all my Excel needs.

http://npoi.codeplex.com/

Comes with a solution of examples for many common Excel tasks.

like image 34
Paul Alan Taylor Avatar answered Oct 16 '22 13:10

Paul Alan Taylor