Quantcast
Viewing all 448 articles
Browse latest View live

Created Unassigned: Date issue with ExcelReaderFactory.CreateBinaryReader() [12993]

We are facing issue with date in .xls file.When we read the file using ExcelReaderFactory.CreateBinaryReader() all the dates availed in excel file converting to a number.

Dll version we are using is 2.1.2.0

How can we solve this issue any idea?


code we used :
public DataTable getDataTableOfExcel(Stream stream, string filename, bool IsFirstRowHasHeader)
{
try
{
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

excelReader.IsFirstRowAsColumnNames = IsFirstRowHasHeader;
DataSet ds = excelReader.AsDataSet();
DataTable dt = ds.Tables[0].Copy();
return dt;
}
catch (Exception ex)
{
Logger.logError(logforimportrecipients, ex);
throw ex;
}
}

Created Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? How can I help to get this resolved ASAP?

Commented Unassigned: Date issue with ExcelReaderFactory.CreateBinaryReader() [12993]

We are facing issue with date in .xls file.When we read the file using ExcelReaderFactory.CreateBinaryReader() all the dates availed in excel file converting to a number.

Dll version we are using is 2.1.2.0

How can we solve this issue any idea?
Check the attachment to get better idea.


code we used :
public DataTable getDataTableOfExcel(Stream stream, string filename, bool IsFirstRowHasHeader)
{
try
{
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

excelReader.IsFirstRowAsColumnNames = IsFirstRowHasHeader;
DataSet ds = excelReader.AsDataSet();
DataTable dt = ds.Tables[0].Copy();
return dt;
}
catch (Exception ex)
{
Logger.logError(logforimportrecipients, ex);
throw ex;
}
}
Comments: ** Comment from web user: DanielRousseau **


I think you can solve your problem by either

a) using the following method from ExcelReaderFactory to create the binary reader:

```
public static IExcelDataReader CreateBinaryReader(Stream fileStream, bool convertOADate)
```

with convertOADate set to true.

OR

b) retrieving the data set using method

```
/// <summary>
///Read all data in to DataSet and return it
/// </summary>
/// <param name="convertOADateTime">if set to <c>true</c> [try auto convert OA date time format].</param>
/// <returns>The DataSet</returns>
DataSet AsDataSet(bool convertOADateTime);
```

again with convertOADateTime set to true.

Commented Unassigned: Date issue with ExcelReaderFactory.CreateBinaryReader() [12993]

We are facing issue with date in .xls file.When we read the file using ExcelReaderFactory.CreateBinaryReader() all the dates availed in excel file converting to a number.

Dll version we are using is 2.1.2.0

How can we solve this issue any idea?
Check the attachment to get better idea.


code we used :
public DataTable getDataTableOfExcel(Stream stream, string filename, bool IsFirstRowHasHeader)
{
try
{
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

excelReader.IsFirstRowAsColumnNames = IsFirstRowHasHeader;
DataSet ds = excelReader.AsDataSet();
DataTable dt = ds.Tables[0].Copy();
return dt;
}
catch (Exception ex)
{
Logger.logError(logforimportrecipients, ex);
throw ex;
}
}
Comments: ** Comment from web user: anwar_s24 **

Thank you for you reply.
I am using the code as you given above(i.e using bool convertOADate option) but still same issue.
Can you check my code once here,
---------------------------------------------
FileStream Stream = new FileStream(Path.Combine("E:\\", "DOB_Test_XLS.xls"), FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo("DOB_Test_XLS.xls");
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(Stream, true);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(Stream);

excelReader.IsFirstRowAsColumnNames = false;
DataSet ds = excelReader.AsDataSet();
--------------------------------------------------------
am i doing any mistake here?
And i can't use 2nd way(retrieving the data set using method), because the file may contains minimum of 500k records .This raises performance issue again to convert all values to date time.

Commented Unassigned: Date issue with ExcelReaderFactory.CreateBinaryReader() [12993]

We are facing issue with date in .xls file.When we read the file using ExcelReaderFactory.CreateBinaryReader() all the dates availed in excel file converting to a number.

Dll version we are using is 2.1.2.0

How can we solve this issue any idea?
Check the attachment to get better idea.


code we used :
public DataTable getDataTableOfExcel(Stream stream, string filename, bool IsFirstRowHasHeader)
{
try
{
IExcelDataReader excelReader = null;
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Extension.ToLower().Equals(".xls"))
//1. Reading from a binary Excel file ('97-2003 format; *.xls)
excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
else
//2. Reading from a OpenXml Excel file (2007 format; *.xlsx)
excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

excelReader.IsFirstRowAsColumnNames = IsFirstRowHasHeader;
DataSet ds = excelReader.AsDataSet();
DataTable dt = ds.Tables[0].Copy();
return dt;
}
catch (Exception ex)
{
Logger.logError(logforimportrecipients, ex);
throw ex;
}
}
Comments: ** Comment from web user: anwar_s24 **

I got the expected result finally just by doing change in this line.

DataSet ds = excelReader.AsDataSet(true);

thank you

New Post: Security Exception while trying ExcelReaderFactory.CreateOpenXmlReader(stream);

I'm having the same problem on my server, somebody have a fix?

Commented Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.
Comments: ** Comment from web user: Ian1971 **

It was using Nuget...but not for all the projects. I'll update it.

Commented Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.
Comments: ** Comment from web user: Ian1971 **

It was strange because manage packages for solution seemed to think it was installed, but it wasn't


Edited Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.

Source code checked in, #88259

Fixed 4.5 SharpZipLib ref and increased version number

Closed Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.
Comments: Resolved with changeset 88259: Fixed 4.5 SharpZipLib ref and increased version number

Source code checked in, #88260

New Post: Security Exception while trying ExcelReaderFactory.CreateOpenXmlReader(stream);

Xlsx files have to be unzipped. Does your application have permissions to the temp folder?

Commented Unassigned: ExcelReaderFactory.CreateBinaryReader fails [12992]

Pretty simple; code is as follows:

FileInfo thisfinfo = Utilities.GetFileInFolderByIndex(1, wipboardreports_folderpath);
FileStream stream = File.Open(thisfinfo.FullName, FileMode.Open, FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);

Fails on line three.

Exception information:
OUTPUT:
"
...
...
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: An item with the same key has already been added.
"

CALL STACK:
"
Excel.4.5.dll!Excel.ExcelBinaryReader.readWorkBookGlobals() Line 244
Excel.4.5.dll!Excel.ExcelBinaryReader.Initialize(System.IO.Stream fileStream) Line 917
Excel.4.5.dll!Excel.ExcelReaderFactory.CreateBinaryReader(System.IO.Stream fileStream) Line 24
Project2.exe!MyTestSystem.Program.Main() Line 48 + 0x9 bytes

"


System information:
OS: Windows 7 64 bit
Compiler: Visual studio default?


Thanks to anyone for your help!
Comments: ** Comment from web user: Ian1971 **

It looks like it the spreadsheet may have a duplicated format record.

I recommend downloading the source code and checking the line it breaks on. A fix might be to add an additional line to first check that a index isn't already present in the the formats dictionary.

I don't have time to do this myself right now though.

Where did the xls come from?

Commented Unassigned: Multithreaded Read [12936]

There seems to be an issue in Excel/Log/LogManager.cs if you concurrently read from multiple different xlsx files.

I fixed the issue by moving the sync-lock to cover up ContainsKey-Check too

From

```
public static ILog Log(string objectName)
{
ILog result = null;

if (_dictionary.ContainsKey(objectName))
result = _dictionary[objectName];

if (result == null)
{
lock (_sync)
{
result = Excel.Log.Log.GetLoggerFor(objectName);
_dictionary.Add(objectName, result);
}
}

return result;
}
```

to

```
public static ILog Log(string objectName)
{
ILog result = null;

lock (_sync)
{
if (_dictionary.ContainsKey(objectName))
result = _dictionary[objectName];

if (result == null)
{
result = Excel.Log.Log.GetLoggerFor(objectName);
_dictionary.Add(objectName, result);
}
}

return result;
}
```
Comments: ** Comment from web user: Ian1971 **

Thanks. I really need to move this project to github so this stuff is easier.


Reopened Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.

Commented Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.
Comments: ** Comment from web user: arangas **

This fixed Excel.4.5 but not Excel.4.0 I'm afraid. That is still pointing to the wrong version of SharpZipLib.

Are you having fun yet?!

Commented Unassigned: ExcelDataReader 2.1.2.2 references incorrect SharpZipLib version in NuGet package in .NET 4.x versions [12996]

Due to some problems resolving SharpZipLib on my project's Test and Stage environments, I've found that ExcelDataReader has been built against a different version to what the NuGet package states.

NuGet states 0.86 is required but when my code that references Excel.dll runs, it says it can't resolve 0.85. Looking at the source, both Excel.4.0.csproj and Excel.4.5.csproj reference 0.85 but Excel.csproj references 0.86.

I've tried to use binding redirects but can't get them to reliably work.

Which is incorrect - the NuGet package or the references? If you are looking to standardize on a particular version across projects perhaps consider the [SharpZipLib NuGet package](http://www.nuget.org/packages/SharpZipLib). It may help alleviate this problem in the future.
Comments: ** Comment from web user: Ian1971 **

The 4.0 version isn't published to nuget. The problem is that somebody upgraded that project and it will only let me open it on Windows 8 so I am unable to modify it. The 2.0 version will still work ok on 4.0 anyway.

New Post: Read Formula?

Is there a way to read the cell formula instead of the cell value?

New Post: Read Formula?

Not currently. You could probably get at the formula if you dig into the library, but there is a bit of a learning curve figuring out the excel format.
Viewing all 448 articles
Browse latest View live