Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all 448 articles
Browse latest View live

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

$
0
0
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: lstrange123 **

I had to use the Boolean flag for converting dates both when creating the reader and extracting the data set. When I did this it worked.
.
.
.
IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(file.InputStream, true);

excelReader.IsFirstRowAsColumnNames = true;
DataSet result = excelReader.AsDataSet(true);
.
.
.


Commented Unassigned: IndexOutOfRangeException - array for cell values too small [11881]

$
0
0
I think the following line in method ExcelBinaryReader.readWorkSheetRow() is wrong:
```
m_cellsValues = new object[m_maxCol];
```
Reason:
m_maxCol holds the index of the last column, not the column count. We get a "one-off" here. Just fix the line like so:
```
m_cellsValues = new object[m_maxCol+1];
```
Comments: ** Comment from web user: specialist_ **

I have IndexOutOfRangeException when I import excel files in old format
[details](http://dev-doc.blogspot.com/2015/02/c-exceldatareader-indexoutofrangeexcept.html)

Created Unassigned: cell values are not updated when using a formula. Required to open Excel file [13458]

$
0
0
Hi,

First of all, I need to say that the ExcelDataReader is a very nice feature. I am already using it for a while now and it a pretty good way to read excel files without having MS-Office installed.

Unfortunately, I encountered an issue with reading data in Excel files (using excelReader.AsDataSet()).

Cell valuas that rely on a formula are not updated.

I.e. when I use a formula to manipulate a date. Lets say: =TODAY()-10 and I read it on the day that I opened and save the Excel file it is retrieved properly.

But when I read it the next day (or any day in the future) without touching the Excel-file, I recieve the outcome of the formula as when it was last saved.

Is this familiar behaviour and is there a solution? It makes no sence to reopen and save the excel file each time prior to reading the data using the ExcelDataReader.

Dying for an answer here...

Kind regards

New Post: problem open xls

$
0
0
hi all,
i have a problem opening an excel that i receive from third party...
problem is in 'public static XlsBiffRecord GetRecord' on the step 'uint ID = BitConverter.ToUInt16(bytes, (int)offset);' (destination matrix is not enought big....).
values:
'bytes'=[4096]
'offset'=4095

but if i open the excel and save it dll is working fine.
someone have the same problem?!

in case i could attach the xls to try.
thank in advance.

Created Unassigned: Please remove dependency on SharpZipLib its GPL [13480]

$
0
0
Please change SharpZipLib to something with a less restrictive license like DotNetZip or 7ZIP SDK for C#.

New Post: Problems reading XLSX created in SAP

$
0
0
An interesting one this - I've been using ExcelDataReader for ages without problems, but I've just had a problem reading an Open XML spreadsheet created with SAP.

Trying .AsDataSet gives out of memory (ie, looping), while using .Read gives correct results for the first row, then .IsDbNull for every other row - and also loops.

If the spreadsheet is opened and saved in Excel (or OpenOffice), everything is fine.

I had a look at the xml contents, and notices that in xl\worksheets\sheet1.xml, the 1st sheetdata\row has r=0 not r=1. But the 2nd row is r=2!

Clearly, this is a problem with SAP not ExcelDataReader. But is it easily resolved in ExcelDataReader?

ExcelDataReader version 2.1.2.3, Net 2.0

I can't post the whole sheet as it's client data, but here's the relevant part, with r="0" not r="1":
<sheetData>
    <row r="0" spans="">
      <c r="A1" s="1" t="s">
        <v>202</v>
      </c>
      <c r="B1" s="1" t="s">
        <v>203</v>
      </c>
    </row>
    <row r="2" spans="1:12">

New Post: Problems reading XLSX created in SAP

$
0
0
Have now had a look at the source code, and I think the problem's in ExcelOpenXMLReader.cs, ReadSheetRow. There's a section
            if (_emptyRowCount != 0)
            {
                _cellsValues = new object[sheet.ColumnsCount];
                _emptyRowCount--;
                _depth++;

                return true;
            }
Once _emptyRowCount < 0 this will loop.

Will now find out how to post this on GitHub...

Created Unassigned: The directory is not empty [13502]

$
0
0
Below issue is raised randomly in one of our server. It is replicated very randomly.

Error Message :The directory is not empty.
Error InnerException :
Error Occured In Target :Void DeleteHelper(System.String, System.String, Boolean)
Error StackTrace : at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)
at ExcelFrameWork.Core.ZipWorker.CleanFromTemp() at iSOFT.ExcelFrameWork.Core.ZipWorker.Dispose(Boolean disposing) in D:\icmt621\iCMTv50~xgsivasubrama4\iCMTv50\ToolsFrame\ToolsFrame\ExcelFrameWork\ExcelReader\Core\ZipWorker.cs:line 232
at ExcelFrameWork.Core.ZipWorker.Dispose() in \ToolsFrame\ToolsFrame\ExcelFrameWork\ExcelReader\Core\ZipWorker.cs:line 219
at ExcelFrameWork.ExcelOpenXmlReader.Close() in \ToolsFrame\ToolsFrame\ExcelFrameWork\ExcelReader\ExcelOpenXmlReader.cs:line 351
at DeploymentToolsFrame.CreateExcelFile.ReadDataFromExcel(String Filename) in \ToolsFrame\ExcelManager\CreateExcelFile.cs:line 208
at DeploymentToolsFrame.ManageExcel.Read(String ExFilePath, String tabName, String Query, String WhereCondition, DataTable& dtExcel) in \ToolsFrame\ToolsFrame\ExcelManager\ManageExcel.cs:line 264
at DeploymentSynchronize.ResolveSyncData.GetSyncDataTable() in \ToolsFrame\ToolsFrame\Configuration\ResolveSyncData.cs:line 184

Reviewed: 2.1.2.0 (Mar 19, 2015)

$
0
0
Rated 4 Stars (out of 5) - hi... this is very good. But i want to know, how to allow access mixed data types using this. Because there are both text and numeric data types in my one excel sheet column.

Reviewed: 2.1.2.0 (Mar 19, 2015)

$
0
0
Rated 4 Stars (out of 5) - hi... this is very good. But i want to know, how to allow access mixed data types using this. Because there are both text and numeric data types in a excel sheet column.

Created Unassigned: Excel DataReader is not reading the data from xls file [13523]

$
0
0
Hi,

I have generated an xls file by using nuget closedxml class,
here is the code,
using (MemoryStream ms = new MemoryStream())
{
using (ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook())
{
wb.AddWorksheet(table);
wb.Style = null;
wb.SaveAs(ms);
response.ExportObject = ms.ToArray();
}
}

the xls file was downloaded with some data. and I am uploading the same file again after updating some data in that xls file and excel reader is not converts to datatable.
here is the code for read from stream.

byte[] fileObject;

using (var binaryReader = new BinaryReader(file.InputStream, System.Text.Encoding.UTF8))
{
fileObject = binaryReader.ReadBytes(file.ContentLength);
}

using (var stream = new MemoryStream(fileObject))
{
IExcelDataReader excelReader = (fileType == FileType.XLS) ? ExcelReaderFactory.CreateBinaryReader(stream) : ExcelReaderFactory.CreateOpenXmlReader(stream);
excelReader.IsFirstRowAsColumnNames = true;
dataSet = excelReader.AsDataSet();
excelReader.Close();

}

file.InputStream is uploaded file [HttpPostedFileBase]

Thanks in advance

Created Unassigned: Will not open binary Excel file [13556]

$
0
0
Hi

We cannot get the ExcelDataReader to open the attached file. We receive the file from a 3rd party, I do not know how they are generating the file. If we open the file in Excel and resave as an xls file the ExcelDataReader can open it. The file after saving from Excel is different than the file supplied to us.

The file is definitely not in openExcel format.

Commented Unassigned: Build scripts for compact framework is out of date [13246]

$
0
0
The latest code uses the var type, which is only supported on framework 3.0+. The batch files for the compact framework is still linking to version 2.0, which will not build. I have already updated my own local copy, but just wanted to point it out so it can be updated in the source. Thanks!
Comments: ** Comment from web user: twisterat57 **

Hi,
I have tryed to get the latest version on Master branch and Develop Branch + some previous commits and i have always the same issue while trying to compile in compact framework... Can you please upgrade the source or specify at least witch version should we user for compact framework?

Created Unassigned: Can't reference column by name? (non-DataTable) [13568]

$
0
0
How do I reference a field by it's (first) column name when not using a DataTable?

while (excelReader.Read())
{
var branch = excelReader["Branch"].ToString(); // <-- I get a __NotSupportedException__

Also, it seems the "IsFirstRowAsColumnNames" property is ignored if you're enumerating the reader? I checked a value by index and it was the header row.

Commented Unassigned: Can't reference column by name? (non-DataTable) [13568]

$
0
0
How do I reference a field by it's (first) column name when not using a DataTable?

while (excelReader.Read())
{
var branch = excelReader["Branch"].ToString(); // <-- I get a __NotSupportedException__

Also, it seems the "IsFirstRowAsColumnNames" property is ignored if you're enumerating the reader? I checked a value by index and it was the header row.
Comments: ** Comment from web user: PeterB **

Unusually, if you don't specify __IsFirstRowAsColumnNames = true;__ the data from the reader will be NULL.


Reviewed: 2.1.2.0 (Apr 29, 2015)

$
0
0
Rated 4 Stars (out of 5) - Very good but a bug with not reading last column from xls spreadsheets is an issue.

New Post: Retrieve sheet name

$
0
0
Hello,
I am new using this cool utility and since I am reading heavy documents I cannot use the function "AsDataSet()".
How can I obtain the sheet name of the current sheet that I am looping through?
Excel.IExcelDataReader r;
            if (string.Compare(ext, ".xls") == 0) r = Excel.ExcelReaderFactory.CreateBinaryReader(file.InputStream, Excel.ReadOption.Loose);
            else r = Excel.ExcelReaderFactory.CreateOpenXmlReader(file.InputStream);

            do
            {
                // Some initialization stuff
             
                //Loop through data sheet
                while (r.Read())
                {
                   //Logic
                }
            } while (r.NextResult());

New Post: Retrieve sheet name

$
0
0
I just found out there is a property called "Name" which is the sheetname of my current result.

Sorry for any inconvenience

New Post: reader.AsDataSet() throws an OutOfMemory exception with even not very big excel files (30 meg)

$
0
0
Same as jbice question.: How does the IDataReader interface work if there are multiple worksheets in the Excel file? Is there a way to specify which worksheet you are iterating through?

New Post: Issue in converting macro enabled excel to dataset using openxml reader

$
0
0
Hi ,
Using openxml i have downloaded macroenabled excel and just opened the downloaded file using spreadsheetdocument and close it with out doing any modifications.
When i pass this file to ExcelReader it is showing empty dataset.
But if i manually open the downloaded file and save it with out doing any changes, then upload it
it is working fine.

Please help me out. Please
Viewing all 448 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>