C # and Excel Files

I need to create a program that can read / write to an Excel file. Should I use OleDB or use an Excel object? What are the advantages of one over the other, and where can I read to start implementing this?

+3
source share
7 answers

I had to do this recently, and I found NPOI ( http://npoi.codeplex.com/ ), especially if I needed to generate binary .xls files that did not cause any confusing errors for the client about file types.

See this blog post for more information. You will also find that since this is a port of an existing structure, there are many useful source structures available that apply to the port.

+4
source

Excel automation may be messy and will not help if your program is designed to run on a web server, but it will give you full access to reading, editing, and creating Excel files.

OLEDB Excel 1998-2003, Excel 2007, ( "", - , ..), , ASP.NET.

( , OOXML Excel Excel (xlsx) OLEDB. , .)

, ASP.NET, , Excel. ( , / Excel XML Excel 2002-2007, ), .

, , / Excel BIFF ( 1997-2003). .

+3

, , , . , , csv. Excel csv . Voilla, Excel.

+1

SpreadsheetGear .NET - , Excel, Excel (xls xlsx) Excel, OleDb - , .NET.

.

: SpreadsheetGear LLC

+1

/ excel , Excel Jetcell.NET.

DataSet, DataTable excel. excel (xls, xlsx) excel , . # excel files .

+1

, CarlosAg". Excel . .

0

you don’t need a third-party tool to read / write excel files ... everything you need is already included in namspace Microsoft.Office.Interop.Excel;
first create an excel file and name it, for example .. test1.xls ... or something else here is the code you need:

using Excel = Microsoft.Office.Interop.Excel;
Excel.Application AppName = new Excel.Application();
Excel.Workbook bookName = AppName.Workbooks.Open(C:\....\test1);
Excel.Worksheet sheetName = AppName.Worksheets.get_Item(1);
sheetName.Rows[5].Cells[5].Value = "hello!";  //that writes hello in cell 5,5 in test1.xls
string box;
box = sheetName.Rows[10].Cells[10].Value;  //that reads the value of 10,10 cell in test1.xls and place it in box variable
0
source

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


All Articles