Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
20
Reply
How to read a excel file in c#?
Dinesh Santhalingam
Jan 24 2017 4:26 AM
536
Reply
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);
}
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
20
)
Next Recommended Forum
Invoice System in c#
Parallel Robocopy