database - To read/write from excel spreadsheet using C# -


I need to create a program that writes some data in Excel spreadsheet

I also know Not sure where to start, with the first name, last name, phone number, e-mail with each line, some basic depending on the line. If someone can tell me which legislatures will be in context and perhaps point me to a website or a book that involves writing / reading data from Excel spreadsheets through a C # program Which would be great

Many thanks.

Add a reference to Microsoft.Office.Interop.Excel.

Assume that you have that data location somewhere else, and your model looks like something

  class contact {public string first name {get; Set; } Public string last name {get; Set; } Public String Email {get; Set; } Receive the public string phone number { Set; }}   

You can import it into Excel

  application excelapp = new application (); Excelapp.Visible = True; _Workbook Workbook = (_Workbook) (excelapp.Workbooks.Add (Type.Missing)); _ Worksheet Worksheet = (_ Worksheet) Workbook. ActiveSite; Worksheet Seals [1, 1] = "First name"; Worksheet Seals [1, 2] = "Last name"; Worksheet Seals [1, 3] = "Email"; Worksheet Seals [1, 4] = "phone number"; Int row = 1; Foreign exchange (various contacts in contact) {line ++; Worksheet Seals [row, 1] = contact first name; Worksheet Seals [row, 2] = contact. Last name; Worksheet Seals [row, 3] = contacts. E-mail; Worksheet Seals [row, 4] = contacts. Phone number; } ExcelApp.UserControl = true;   

You can read more about the Excel Interop Library here:

Comments