Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcelReader latest version(3.7.0-develop00310) is not working #1

Open
svadivel0006 opened this issue Sep 8, 2021 · 6 comments
Open

Comments

@svadivel0006
Copy link

svadivel0006 commented Sep 8, 2021

Hi,

ExcelReader latest version(3.7.0-develop00310) is not working

Code:

FileStream stream = new FileStream(@"\TestCreateBugXlxs.xlsx", FileMode.Open, FileAccess.Read);

IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

DataSet result = excelReader.AsDataSet();

==========================

Here the errors are displayed

"CS0246 The type or namespace name 'DataSet' could not be found (are you missing a using directive or an assembly reference?) TestExcelData.cs 20 Active"

and

"CS1061 'IExcelDataReader' does not contain a definition for 'AsDataSet' and no accessible extension method 'AsDataSet' accepting a first argument of type 'IExcelDataReader' could be found (are you missing a using directive or an assembly reference?) TestExcelData.cs 20 Active"

Added the below mentioned system references:

System.xml
System.Data
System.Data.DataSetExtemsion

Kindly update how this can be resolved

Regards,
Vadivel Sekar

@svadivel0006
Copy link
Author

ExcelDataReader_CompilationError
Hi,

Herewith I have attached the screenshot for your reference

Regards,
Vadivel Sekar

@svadivel0006
Copy link
Author

Hi,

After adding the "ExcelDataReader.DataSet", the issue was resolved.

The below mentioned code is not working, confirm whether this depreciated

Depreciated Code:

//DataSet - Create column names from first row
excelReader.IsFirstRowAsColumnNames = true;

The custom code is working:

using (var reader = ExcelReaderFactory.CreateOpenXmlReader(stream))
{
var config = new ExcelDataSetConfiguration()
{
ConfigureDataTable = (tableReader) => new ExcelDataTableConfiguration()
{
UseHeaderRow = true
}
};

            var result1 = reader.AsDataSet(config);
              }

Please confirm whether the logic for access the data set values should be implemented inside the method/block itself or can be accessed out of the block too

Regards,
Vadivel Sekar

@svadivel0006
Copy link
Author

svadivel0006 commented Sep 9, 2021

Hi,

Kindly find the updated issue details:

  1. When the ".xlsb" file is read with the "FilterRow = rowReader => rowReader.Depth > 0" in configuration section, it is not working as expected, even when Filter row is commented out, the same output is generated.
  2. When the ".xlsb" file is read, the character "d" is randomly generated

Kindly confirm the correctness, find the attachments

Regards,
Vadivel Sekar

ExcelDataReader_ConfigSecIssues
ExcelDataReader_ConfigSecIssues1

@svadivel0006
Copy link
Author

Hi,

Update to the issue.

Added a new sheet such as "Sheet1" and when the below code is executed the success message is displayed and data reading is unsuccessful.

Code:
[TestClass]
public class TestExcelData
{

    [TestMethod]
    public void TestReadExcel()
    {
        FileStream stream = new FileStream(@"TestCreateBugXlsb.xlsb", FileMode.Open, FileAccess.Read);
        //IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
        IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

        var result = excelReader.AsDataSet(new ExcelDataSetConfiguration()
        {
            ConfigureDataTable = (_) => new ExcelDataTableConfiguration()
            {
                UseHeaderRow = true,
                FilterRow = rowReader => rowReader.Depth > 0
            }
        });

        DataTable table = result.Tables["Sheet1"];
       
        for (int i=0; i < table.Rows.Count; i++)
        {
            var col = table.Rows[i];
            for (int j=0; j < col.ItemArray.Length; j++)
            {
                Console.WriteLine("Data : {0}", col.ItemArray[j]);
            }
        }
    }
}

}

Screenshot:

ExcelDataReader_Sheet1_Issue

@svadivel0006
Copy link
Author

Please Note: The issue occurs in ".xlsx" and ".xlsb" files

@rishios
Copy link
Owner

rishios commented Sep 10, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants