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

New Post: Empty cell values

$
0
0
I've used ExcelDataReader previously with great success on both .xls and .xlsx files. I am trying to use it on a new project, but am running into an issue where when I call AsDataSet and then iterate over rows in one of the DataTables, all of the cell values are either empty string or DBNull. What can cause this to occur? The file is an .xls that says its 97-2003 file format.

Thanks for the great library!

Commented Unassigned: GetValue returns empty string for cells in some xls files [11928]

$
0
0
I'm having trouble using GetValue on some xls files. The attached file is one example. GetValue returns an empty string for virtually all text fields (including A1). Looking at the DataTable generated through AsDataSet also has the fields empty when they do in fact have text.
Comments: ** Comment from web user: slide_o_mix **

I am also seeing this issue. I can't upload the spreadsheet that I have because it contains company secrets, but if I use the Invoice xls that moorhs uploaded, I see the same thing.

Commented Unassigned: OpenOffice Table Rows Count problem [12909]

$
0
0
Hi,

I have .xsl file created in Excel 2010. When loading the file with CreateBinaryReader i get all DataTables and rows within them. But when open that file in OpenOffice and Save it without any modifications and then load it again with CreateBinaryReader all DataTables created have one row less then the file created with Excel 2010.

What could be the problem?
Comments: ** Comment from web user: bvolkan **

Any news on this one.

New Post: Empty cell values

$
0
0
  1. Are you using the latest version from nuget?
  2. Download the source code and try the TestApp project and point it at your file. If it is still coming out empty then that particular sheet probably has some oddity that needs debugging in the library. You could either, a) do this yourself, b) post an issue and a sample file that has the problem here and I will attempt to take a look at it.
Your fastest route to a solution though is to try and debug it yourself, as I am maxed out at the moment. If you do debug it yourself and spot a bug in the library then please post the fix, so I can try and incorporate it into the library when I have time.

Cheers
Ian

Commented Unassigned: GetValue returns empty string for cells in some xls files [11928]

$
0
0
I'm having trouble using GetValue on some xls files. The attached file is one example. GetValue returns an empty string for virtually all text fields (including A1). Looking at the DataTable generated through AsDataSet also has the fields empty when they do in fact have text.
Comments: ** Comment from web user: Ian1971 **

I don't have time to debug this at the moment, so you can either wait until I do have time, or attempt to figure it out yourselves.

Good luck!

Commented Unassigned: OpenOffice Table Rows Count problem [12909]

$
0
0
Hi,

I have .xsl file created in Excel 2010. When loading the file with CreateBinaryReader i get all DataTables and rows within them. But when open that file in OpenOffice and Save it without any modifications and then load it again with CreateBinaryReader all DataTables created have one row less then the file created with Excel 2010.

What could be the problem?
Comments: ** Comment from web user: Ian1971 **

Sorry, I tried to reply directly to the email but Codeplex email often doesn't work in my experience.
Anyway, what row is missing? first? last? some other row?
Does the sheet have column headers?

Commented Unassigned: Multithreaded Read [12936]

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

Nice one

Commented Unassigned: OpenOffice Table Rows Count problem [12909]

$
0
0
Hi,

I have .xsl file created in Excel 2010. When loading the file with CreateBinaryReader i get all DataTables and rows within them. But when open that file in OpenOffice and Save it without any modifications and then load it again with CreateBinaryReader all DataTables created have one row less then the file created with Excel 2010.

What could be the problem?
Comments: ** Comment from web user: bvolkan **

Sorry for the delay. Always when file is saved with open office in .xls the first row is missing. Saving the file to .xls with Excel 2007 or higher does no problems. One strange thing: when setting the IsFirstRowAsColumnNames = true, and open a xls saved with Open office I get the column names from the first row.

Thanks,
Boris


Commented Unassigned: GetValue returns empty string for cells in some xls files [11928]

$
0
0
I'm having trouble using GetValue on some xls files. The attached file is one example. GetValue returns an empty string for virtually all text fields (including A1). Looking at the DataTable generated through AsDataSet also has the fields empty when they do in fact have text.
Comments: ** Comment from web user: slide_o_mix **

It looks like there is some issue with XlsBiffSST in the ReadStrings method. Using the attached spreadsheet, one of the strings ends up looking like this:

"˦\0\0\0Block B,4/F., Winful Industrial Building, 15-17 Tai Yip Street, Kwun Tong, Kowloon, Hong "

This means that the next string that is parsed ends up looking like this (truncated), which is actually several strings:

"\0\f\0\07\0\0\0\0\0\0\0\0\09\0\0\0\0Commercial Invoice for Naartjie Clothing ZA One (PTY) Ltd\0\f\0\07\0\0\0\0\0\0\0\0\0\b\0\0\0\0SUPPLIER\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0TARGET EASE INTERNATIONAL LTD\0\f\0\07\0\0\0\0\0\0\0\0\0 \0\0\0\0Logwin Air & Ocean Hong Kong Ltd\0\f\0\07\0\0\0\0\0\0\0\0\02\0\f\0\0\0\0Address:Block B,4/F., Winful Industrial Building, \b\04\0\0\f\0\07\0\0\0\0\0\0\0\0\0o\0\f\0\0\0\0Address: Rm 1101,11/F., MTL Warehouse Bldg, Phase 1,Berth One, Container Port Road, Kwal Chung, N.T. Hong Kong\a\04\0\0\f\0\07\0\0\0\0\0\0\0\0\03\0\0\0\015-17 Tai Yip Street, Kwun Tong, Kowloon, Hong Kong\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0GROUP\0\f\0\07\0\0\0\0\0\0\0\0\0\r\0\0\0\0CHILDREN WEAR\0\f\0\07\0\0\0\0\0\0\0\0\0\0\f\0\0\0\0Telephone: (852)27979785\t\04\0\0\f\0\07\0\0\0\0\0\0\0\0\0\0\f\0\0\0\0Telephone: (852) 27963783\t\04\0\0\f\0\07\0\0\0\0\0\0\0\0\0 \0\0\0\0FINAL DESTINATION - SOUTH AFRICA\0\f\0\07\0\0\0\0\0\0\0\0\0#\0\0\0\0Naartjie Clothing ZA One (PTY) Ltd.\0\f\0\07\0\0\0\0\0\0\0\0\0U\0\f\0\0\0\0Address: Pals Building, 95 Durham Avenue, Salt River, Cape Town, RSA, South Africa.\a\04\0\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0Gender\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0Age\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0TICKET REPORT \0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0DESCRIPTION/ FABRIC CONTENT\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0NAARTJIE P.O.# / STYLE #\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0DETAIL DESCRIPTION\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0WEIGHT PER UNIT (KG)\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0TOTAL NET WEIGHT (KG)\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0TOTAL GROSS WEIGHT (KG)\0\f\0\07\0\0\0\0\0\0\0\0\0\n\0\0\0\0TOTAL CTNS\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0GIRLS\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0KID\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0PAIR\0\f\0\07\0\0\0\0\0\0\0\0\0^\0\f\0\0\0\0Address: Block A,Black River Park North 2 Fir Street,Observatory 7925,Cape Town, South Africa.\a\04\0\0\f\0\07\0\0\0\0\0\0\0\0\0\v\0\0\0\0TOTAL DOZEN\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0TOTAL:\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\01) \0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0COUNTRY OF ORIGIN : \0\f\0\07\0\0\0\0\0\0\0\0\0\r\0\0\0\0MADE IN CHINA\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0BANK DETAILS: \0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0WING HANG BANK LTD.\0\f\0\07\0\0\0\0\0\0\0\0\0a\0\0\0\0CASTLE PEAK ROAD BRANCH, SHOP NO. 2, 253-259 CASTLE PEAK ROAD, CHEUNG SHA WAN, KOWLOON, HONG KONG\0\f\0\07\0\0\0\0\0\0\0\0\0K\0\0\0\0ACCOUNT NAME: TARGET EASE INTERNATIONAL LIMITED, ACCOUNT NO. 821-353858-001\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0MFY NAME & ADDRESS: \0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0GAOPENG SHOES FACTORY \0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\04) \0\f\0\07\0\0\0\0\0\0\0\0\0C\0\0\0\0101 LOBAO TOWN,WAN CHUN RD,SHANSHUI,FOSHAN,GUANGDONG PROVINCE,CHINA\0\f\0\07\0\0\0\0\0\0\0\0\0\n\0\0\0\0MID CODE: \0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\0CNGAOPEN101FOS\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0\0\05) \0\f\0\07\0\0\0\0\0\0\0\0\0\r\0\0\0\0POSTAL CODE :\0\f\0\07\0\0\0\0\0\0\0\0\0\f\0\0\0\0TE-132-SA/13\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0TAKKIES MESH KGÎ\0\0Canvas Mary Jane Mesh Bow woven canvas takkie with velcro for fastening over the feet, with rubber soles. Mesh bow and trim under bind trim, with eyelits on outside of takkie. Embroidery outside showing.\r\0\0\0\0GIRLS TAKKIES\0\f\08\07\0\0\0\0\0\0\0\0\0\0\0\0\0N/A\0\f\08\07\0\0\0\0\0\0\0\0\0\0\0\0\0GKA3130SPT14SA\0\f\08\07\0\0\0\0\0\0\0\0\0`\0\0\0\0TOTAL INVOICE VALUE: U.S. DOLLARS TEN THOUSAND SEVEN HUNDRED NINETY ONE AND CENTS SIXTY ONLY.***\0\f\0\07\0\0\0\0\0\0\0\0\0\0\0STORE NAME & NO\0\0BOX NO\0\0WEIGHT\0\0ALU\0\0Style\v\0\0Description\0\0Size\0\0Colour\t\0\0P6691S188\0\0Size 6\f\0\0PINK. MUFFIN\t\0\0P6691S189\0\0Size 7\t\0\0P6691S190\0\0Size 8\t\0\0P6691S191\0\0Size 9\t\0\0P6691S192\a\0\0Size 10\t\0\0P6691S193\a\0\0Size 11\t\0\0P6691S194\a\0\0Size 12\t\0\0P6691S195\a\0\0Size 13\t\0\0P6691S196\0\0Size 1\t\0\0P6691S197\0\0Size 2\n\0\0\0\0WATERFRONT\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 130\0\f\08\07\0\0\0\0\0\0\0\0\0\b\0\0\0\08.37 KGS\0\f\08\07\0\0\0\0\0\0\0\0\0\0\0\0\0GKA3130SPT14SA\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 131\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 132\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 133\0\f\08\07\0\0\0\0\0\0\0\0\0\t\0\0\0\0PAVILLION\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 134\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 135\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0SANDTON\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 136\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 137\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 138\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 139\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 140\0\f\08\07\0\0\0\0\0\0\0\0\0\b\0\0\0\0EASTGATE\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 141\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 142\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 143\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 144\0\f\08\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0\0\a\0\0\0\0EWS 188\0\f\08\07\0\0\0\0\0\0\0\0\0\n\0\0\0\0CLEARWATER\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 189\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 190\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 191\0\f\08\07\0\0\0\0\0\0\0\0\0\0\0\0\0ILANGA\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 192\0\f\08\07\0\0\0\0\0\0\0\0\0\v\0\0\0\0BEDFORDVIEW\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 193\0\f\08\07\0\0\0\0\0\0\0\0\0\0\0\0\0MALL OF THE NORTH\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 194\0\f\08\07\0\0\0\0\0\0\0\0\0\n\0\0\0\0BLUE ROUTE\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 195\0\f\08\07\0\0\0\0\0\0\0\0\0\b\0\0\0\0WEBSTORE\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 196\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWS 197\0\f\08\07\0\0\0\0\0\0\0\0\0\t\0\0\0\0NICHOLWAY\0\f\08\07\0\0\0\0\0\0\0\0\0\a\0\0\0\0EWT 189\0\f\08\07\0\0\0\0\0\0\0\0\0%\0\0Naartjie Kids - STORE NUMBER LISTING\n\0\0STORE NAME\0\0NUMBER\t\0\0ATTERBURY\0\008\v\0\0BEDFORDVIEW\0\024\n\0\0BLUE ROUTE\0\026\n\0\0CANAL WALK\0\010\t\0\0CAVENDISH\0\005\n\0\0CLEARWATER\0\021\0\0CRESTA\0\012\b\0\0EASTGATE\0\004\v\0\0EPSOM DOWNS\0\009\0\0GARDEN ROUTE MALL\0\023\a\0\0GATEWAY\0\013\b\0\0HOUT BAY\0\006\0\0ILANGA\0\022\0\0IRENE\0\020\b\0\0LA LUCIA\0\019\0\0MALL OF THE NORTH\0\025\0\0MENLYN\0\011\v\0\0MORNINGSIDE\0\018\t\0\0NICHOLWAY\0\028\0\0ONLINE / WEBSTORE\0\027\t\0\0PAVILLION\0\002\a\0\0SANDTON\0\003\r\0\0SOMERSET MALL\0\015\v\0\0TYGERVALLEY\0\017\0\0V&A

Commented Unassigned: Example of excel file returning no datasets - OpenXmlReader [12455]

$
0
0
FileStream stream = File.Open(excelFilePath, FileMode.Open, FileAccess.Read);
excelReader = Excel.ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet();

result is null for the attached file.
Comments: ** Comment from web user: bvolkan **

I suppose that this file was created with Excel 2007 (saved as Excel Workbook). I have the same problem. When i Opened this file in 2010 and saved it, everything passed. Any new on this one?

Commented Unassigned: Example of excel file returning no datasets - OpenXmlReader [12455]

$
0
0
FileStream stream = File.Open(excelFilePath, FileMode.Open, FileAccess.Read);
excelReader = Excel.ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet();

result is null for the attached file.
Comments: ** Comment from web user: Ian1971 **

This particular file fails in ICSharpCode.SharpZipLib with this error
"Size mismatch between central header(587) and local header(0)" so I'm not sure whether it is a problem with the file itself or SharpZipLib. I don't have time to do any further investigation right now, but if you wanted to raise it with developers in the zip library that would be much appreciated.

Commented Unassigned: Example of excel file returning no datasets - OpenXmlReader [12455]

$
0
0
FileStream stream = File.Open(excelFilePath, FileMode.Open, FileAccess.Read);
excelReader = Excel.ExcelReaderFactory.CreateOpenXmlReader(stream);
DataSet result = excelReader.AsDataSet();

result is null for the attached file.
Comments: ** Comment from web user: bvolkan **

Yes I've got the same problem it was zip library ICSharpCode.SharpZiplib. I will move this one there if it is OK with Maxplod...?

Commented Unassigned: First row always skipped (CreateBinaryReader, AsDataSet) [12647]

$
0
0
when reading a .xls (binary) file, the first row is missing in the returned datatables, even if IsFirstRowAsColumnNames=false

__reason__ :
in method 'readWholeWorkSheetNoIndex', line : justAddedColumns = true; is not at the right place

__Patch__ :
```
if (triggerCreateColumns)
{
if (_isFirstRowAsColumnNames || (_isFirstRowAsColumnNames && m_maxRow == 1))
{
for () {...}
justAddedColumns = true; // added by jerome.raffalli
}
else {...}
triggerCreateColumns = false;
// justAddedColumns = true; // removed by jerome.raffalli
table.BeginLoadData();
}

```
Comments: ** Comment from web user: bvolkan **

Thanks jerome raffalli. I got this bug when saving the file with open office.

New Post: Import subset of Data from Excel

$
0
0
I have just had to implement something like this when we switched from OLE DB to the Excel Data Reader to read Excel files in our product. I modified the Excel Data Reader code to make it possible to:
  • read a specific worksheet into a data table (instead of reading the entire workbook into a dataset and then retrieving the data table of interest)
  • read a specific cell range from a specific worksheet into a data table
I am about to contact the Ian1971 to see if it would be possible to integrate these changes into the Excel Data Reader.

Commented Unassigned: OpenOffice Table Rows Count problem [12909]

$
0
0
Hi,

I have .xsl file created in Excel 2010. When loading the file with CreateBinaryReader i get all DataTables and rows within them. But when open that file in OpenOffice and Save it without any modifications and then load it again with CreateBinaryReader all DataTables created have one row less then the file created with Excel 2010.

What could be the problem?
Comments: ** Comment from web user: DanielRousseau **

There is indeed a bug that drops the first row of Open Office .xls files when column names are NOT read from the first row.

The problem is in the method readWholeWorkSheetNoIndex() in ExcelBinaryReader.cs, where
"justAddedColumns = true;" is in the wrong spot. It needs to be moved from right after "triggerCreateColumns = false;" to right after the first for loop since it is only relevant if the first row consist of column names. The method with the fix is shown below.

private void readWholeWorkSheetNoIndex(bool triggerCreateColumns, DataTable table)
{
while (Read())
{
if (m_depth == m_maxRow) break;

bool justAddedColumns = false;
//DataTable columns
if (triggerCreateColumns)
{
if (_isFirstRowAsColumnNames || (_isFirstRowAsColumnNames && m_maxRow == 1))
{
for (int i = 0; i < m_maxCol; i++)
{
if (m_cellsValues[i] != null && m_cellsValues[i].ToString().Length > 0)
Helpers.AddColumnHandleDuplicate(table, m_cellsValues[i].ToString());
else
Helpers.AddColumnHandleDuplicate(table, string.Concat(COLUMN, i));
}
justAddedColumns = true;
}
else
{
for (int i = 0; i < m_maxCol; i++)
{
table.Columns.Add(null, typeof(Object));
}
}

triggerCreateColumns = false;
table.BeginLoadData();
}

if (!justAddedColumns && m_depth > 0 && !(_isFirstRowAsColumnNames && m_maxRow == 1))
{
table.Rows.Add(m_cellsValues);
}
}

if (m_depth > 0 && !(_isFirstRowAsColumnNames && m_maxRow == 1))
{
table.Rows.Add(m_cellsValues);
}
}


Commented Unassigned: OpenOffice Table Rows Count problem [12909]

$
0
0
Hi,

I have .xsl file created in Excel 2010. When loading the file with CreateBinaryReader i get all DataTables and rows within them. But when open that file in OpenOffice and Save it without any modifications and then load it again with CreateBinaryReader all DataTables created have one row less then the file created with Excel 2010.

What could be the problem?
Comments: ** Comment from web user: bvolkan **

Thanks, this was also detected earlyer in this issue
https://exceldatareader.codeplex.com/workitem/1264

Thanks to everyone

New Post: Read column values with Excel Data Reader not working (MVC)

$
0
0
Hi krillezzz
I have just been digging about in your code. I think the issue is that you set data to be a single row
                DataRow data = result.Tables[0].Rows[i];
                System.Diagnostics.Debug.Write(data.Table.Rows[i]["Amortization"]);
Then access a Table within that row and rows within that table. I have tried
                    string val = data[1].ToString();
and that works.
                   string nval = data["Title"].ToString();
Also works

Commented Unassigned: Multithreaded Read [12936]

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

For some reason I can not create pull request for this project.

Please introduce double-check logic like this:

https://gist.github.com/tripolitov/99ea3431437080cf8c63

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

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

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

result = _dictionary[objectName];
}
}

return result;
}
```

New Post: Import subset of Data from Excel

$
0
0
I just replied to your email Daniel if you wanted to send me the changes.

It seems a bit stone age to be emailing changes around, but codeplex forces us into this. I really need to migrate this to github.

Created Unassigned: ExcelReaderFactory.CreateBinaryReader fails [12992]

$
0
0
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!
Viewing all 448 articles
Browse latest View live


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