TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Narayan Mali
NA
56
21.2k
How To find non empty column of excel using c# ?
Jun 26 2014 5:32 AM
please help
i want to fetch only those column of excel having data.
when i am fetching all column i get error while excel adapter fill dataset ExcelAdapter.Fill(ExcelDataSet);"
Error is "to many value"
so i want to fetch those column having data in excel.
thanks in advance
my code is
OleDbConnection con = null;
string FilePath = Server.MapPath(Strfilename);
string FileExt = System.IO.Path.GetExtension(FilePath);
if (FileExt == ".xls")
{
con = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + FilePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"");
}
con.Open();
DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
Session["Dtexl"] = dt;
if (dt.Rows.Count > 0)
{
string getExcelSheetName = dt.Rows[0]["Table_Name"].ToString();
OleDbCommand ExcelCommand = new OleDbCommand(@"SELECT * FROM [" + getExcelSheetName + @"]", con);
OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand);
DataSet ExcelDataSet = new DataSet();
ExcelAdapter.Fill(ExcelDataSet);
Reply
Answers (
3
)
Decode QR Code
How to call a wsdl web service in ASP.NET