Recommended tutorial for reading an Excel file in C #

I have experience with C #, but limited experience using C # to read content from Excel. My task is very simple, just read each column of each row of the Excel document and extract their values.

Any good tutorials or samples for a beginner? I am using VSTS 2008 + C # + .Net 3.5.

I am working with Excel 2007.

+4
source share
3 answers

The Excel 2007 file format is not redundant. Getting the text value of a cell using the Open XML Format SDK 2.0 requires a lot of work. If you are not going to use third-party libraries that you do not know about, you need to deeply penetrate this SDK. There are tutorials, but I don’t know a simple solution even for your simple task.

+2
source

Check this link.

Based on your description, this is enough, but if you need to create an add-in, I would just look at VSTO. just google / bing it, pretty simple :)

+1
source

SpreadsheetGear for .NET will do this. Here is a simple example in a C # console application:

using System; using SpreadsheetGear; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // Load Book.xlsx. IWorkbook workbook = Factory.GetWorkbook(@"c:\Book.xlsx"); // Write the address and formatted text value of each // cell to the console. foreach (IRange cell in workbook.Worksheets[0].UsedRange) Console.WriteLine("{0}='{1}'", cell.Address, cell.Text); } } } 

You can download a free trial here and try it for yourself.

Disclaimer: I have SpreadsheetGear LLC

+1
source

Source: https://habr.com/ru/post/1286534/


All Articles