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);
Loading

Lorine ApplebyPosted Dec 22, 2014, 5:25 AM
The API is from this .NET component for excel processing and as you can see it has a straightforward export of excel sheets to DataTable instances in C#.
Mayur DhavlePosted Jul 3, 2014, 2:47 AM
http://www.codeproject.com/Questions/224074/Excel-finding-the-next-blank-cell-and-populate-it
http://stackoverflow.com/questions/4896230/retrieve-not-empty-rows-in-first-column-of-excel-sheet-via-oledbcommand
http://social.msdn.microsoft.com/Forums/vstudio/en-US/f1308e42-8174-439a-a90f-55405ef7945b/reading-data-from-excel-sheet-without-blank-rows-using-c?forum=wpf
Mayur DhavlePosted Jul 3, 2014, 2:43 AM
Please check if this is working.
C# Code:
---------
Excel.Worksheet sh;
long lastRow;
long fullRow;