I havent heard any such restrictions so far, it could be your connection string issue.
Please try the following methods :
public string GetConnectionString(string FileNamePath, bool HasHeader)
{
string ConnectionString = "";
string Extension = Path.GetExtension(FileNamePath).ToLower();
string BinaryExcelProvider = "Microsoft.Jet.OLEDB.4.0";
string XmlExcelProvider = "Microsoft.ACE.OLEDB.12.0";
string BinaryExcelExtProperties = "Excel 8.0";
string XmlExcelExtProperties = "Excel 12.0";
string XmlMacroExcelExtProperties = "EXCEL 12.0 Macro";
string Provider = "";
string ExtendedProperties = "";
switch (Extension)
{
case ".xls":
Provider = BinaryExcelProvider;
ExtendedProperties = BinaryExcelExtProperties;
break;
case ".xlsx":
Provider = XmlExcelProvider;
ExtendedProperties = XmlExcelExtProperties;
break;
case ".xlsm":
Provider = XmlExcelProvider;
ExtendedProperties = XmlMacroExcelExtProperties;
break;
}
string Header = ";HDR=NO;IMEX=1";
if (HasHeader)
Header = ";HDR=YES;IMEX=1";
string ConnectionStringFormat = "Provider={0};Data Source={1};Extended Properties=\"{2}{3}\";";
ConnectionString = string.Format(ConnectionStringFormat, Provider, FileNamePath, ExtendedProperties, Header);
return ConnectionString;
}
public DataSet ReadWorkSheet(string excelFile)
{
Success = false;
System.Data.DataSet excelDataSet = new DataSet();
string connectionString = this.GetConnectionString(excelFile);
using (OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(connectionString))
{
try
{
objConn.Open();
OleDbDataAdapter cmd = new OleDbDataAdapter("select * from [Sheet1$A1:E10]" , objConn);
cmd.Fill(excelDataSet, "MyData");
cmd.Dispose();
}
catch { }
finally
{
if (objConn != null)
{
objConn.Close();
objConn.Dispose();
}
}
}
return excelDataset
}
Thanks,
Kuthuparakkal