Hi EPPlus team,
an issue with reading xlsx by OleDB reader was found since we have upgraded EPPlus library from 2.8.0.2 to 4.0.4.0.
In case of 4.0.4 output throws OleDbConnection.Open exception:
> "External table is not in the expected format."
although epp 2.8.0 prododuces OleDB compatible result. See following example for demonstration this behavior:
```C#
static void Main()
{
const string name = "Data";
const string ConnectionStringMask = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=\"Excel 12.0;ReadOnly=True;HDR=Yes;IMEX=1;TypeGuessRows=0\";Data Source={0}";
var data = new[]
{
new object[] {"AB", "1/1/2010"},
new object[] {"Test", 1.25}
};
var tmp = new FileInfo(Path.GetTempFileName());
if (tmp.Exists) tmp.Delete();
var file = new FileInfo(Path.ChangeExtension(tmp.FullName, ".xlsx"));
if (file.Exists) file.Delete();
using (var excel = new ExcelPackage(file))
{
var sheet = excel.Workbook.Worksheets.Add(name);
var range = sheet.Cells[2, 2].LoadFromArrays(data);
excel.Workbook.Names.Add(name, range);
excel.Save();
}
var constr = string.Format( ConnectionStringMask, file.FullName );
var dt = new DataTable();
using (var con = new OleDbConnection(constr))
{
con.Open();
var cmd = new OleDbCommand(string.Format("SELECT * FROM [{0}]", name), con);
var reader = cmd.ExecuteReader();
if (reader == null) throw new NoNullAllowedException();
dt.Load(reader);
}
}
```
> Both results ( 2.8.0, 4.0.4 ) are open in MS excel without warnings.
> After open and save in MS excel is content readable in OleDB.
Attached is xlsx produced by version 2.0.8
We need to open the xlsx via OleDb, could you help us with a workaround or fix?
Thank you
an issue with reading xlsx by OleDB reader was found since we have upgraded EPPlus library from 2.8.0.2 to 4.0.4.0.
In case of 4.0.4 output throws OleDbConnection.Open exception:
> "External table is not in the expected format."
although epp 2.8.0 prododuces OleDB compatible result. See following example for demonstration this behavior:
```C#
static void Main()
{
const string name = "Data";
const string ConnectionStringMask = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=\"Excel 12.0;ReadOnly=True;HDR=Yes;IMEX=1;TypeGuessRows=0\";Data Source={0}";
var data = new[]
{
new object[] {"AB", "1/1/2010"},
new object[] {"Test", 1.25}
};
var tmp = new FileInfo(Path.GetTempFileName());
if (tmp.Exists) tmp.Delete();
var file = new FileInfo(Path.ChangeExtension(tmp.FullName, ".xlsx"));
if (file.Exists) file.Delete();
using (var excel = new ExcelPackage(file))
{
var sheet = excel.Workbook.Worksheets.Add(name);
var range = sheet.Cells[2, 2].LoadFromArrays(data);
excel.Workbook.Names.Add(name, range);
excel.Save();
}
var constr = string.Format( ConnectionStringMask, file.FullName );
var dt = new DataTable();
using (var con = new OleDbConnection(constr))
{
con.Open();
var cmd = new OleDbCommand(string.Format("SELECT * FROM [{0}]", name), con);
var reader = cmd.ExecuteReader();
if (reader == null) throw new NoNullAllowedException();
dt.Load(reader);
}
}
```
> Both results ( 2.8.0, 4.0.4 ) are open in MS excel without warnings.
> After open and save in MS excel is content readable in OleDB.
Attached is xlsx produced by version 2.0.8
We need to open the xlsx via OleDb, could you help us with a workaround or fix?
Thank you