I have a excel file.I want to read the file using c#.
Excel file contains following.
- Name subject Marks
- A maths 35
- B maths 50
- C maths 69
- ------------Empty row-----------------
- D maths 36
I am using Interop to read the Excel file .
i want my o/p like below.
- Name subject Marks
- A maths 35
- B maths 50
- C maths 69
- D maths 36
What i did:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Excel = Microsoft.Office.Interop.Excel;
- namespace excel
- {
- class Program
- {
- static void Main(string[] args)
- {
- Excel.Application xlApp = new Excel.Application();
- Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:\dinesh\Sample.xlsx");
- Excel.Worksheet xlWorksheet = xlWorkbook.Sheets[1]; // assume it is the first sheet
- Excel.Range xlRange = xlWorksheet.UsedRange;
-
-
- xlWorkbook.Worksheets.Add(xlWorksheet);
-
- }
- }
- }
-