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

Cannot Read .xlsb file in .NET 7 #637

Closed
rvdingDev opened this issue Jun 14, 2023 · 17 comments · Fixed by #645
Closed

Cannot Read .xlsb file in .NET 7 #637

rvdingDev opened this issue Jun 14, 2023 · 17 comments · Fixed by #645
Labels
Milestone

Comments

@rvdingDev
Copy link

rvdingDev commented Jun 14, 2023

Hello.
I am currently using the trial version of ExcelDataReader in order to read .xlsb files.
In the .NET Framework, reading .xlsb files is well supported, and no errors are seen in the .NET 7.0. However, data is not being properly read within the 'Watch' in the .NET 7.0.
I need help with this part.

I tried to create a reader object using CreateReader() and, made it as DataSet. I also tried to read one line at a time through Read() and read the value through GetValue(). But I can't get it to read properly.
If anything you can do to solve this problem in your current environment, I would greatly appreciate.

Thank you.

@appel1
Copy link
Collaborator

appel1 commented Jun 14, 2023

Do you get any exception or in what way does it not work?

@rvdingDev
Copy link
Author

rvdingDev commented Jun 14, 2023

I'm not sure if I explained it properly because I'm not familiar with English.

I'm having an issue reading data from a Korean Excel file in a UTF-8 encoding environment.
Even though no exceptions are thrown, the Read() method and DataSet aren't functioning as expected.
The number of rows are correctly imported, but the values that should be in each cell are being read as DBNull. Also, while the number of columns are correctly imported, the column names aren't properly read. Instead, they're being generated as 'Column1', 'Column2', etc.

This issue occurs in .NET 7.0.
It worked correctly when I performed a unit test in the .NET Framework.

@appel1
Copy link
Collaborator

appel1 commented Jun 16, 2023

Could you provide me with a sample .xlsb file that reproduces this issue? The .xlsb files I've tried works with .NET 7.0.

Does .xlsx files in Korean work for you?

@rvdingDev
Copy link
Author

rvdingDev commented Jun 16, 2023

I wanted to make a test file, but if I made the file myself, it worked really well. But the object is created as an OpenXmlReader object and is read.

I can't give you the file because the data is prohibited from leaking.
Files are contain many sheet references, file references, and column references in the company excel file.
But I'll show you the results of UnitTest.
image

I am importing the sheet called '#TargetDefine' in the .xlsb file, but the sheet is all written in English and there are no empty cells, and the column 'PatentName' is written in a formula, so I think it comes out properly. String is not working.

I tried cloned and debugged the repository.
The .xlsb file is created as an OpenXmlReader object without being read to the BinaryReader() method through the CreateReader() method, so the AsDataTable method itself.Value is null when proceeding GetValue(i)...

I'm not sure what to do.

Additionally, the .xlsx file works perfectly.

@rvdingDev
Copy link
Author

rvdingDev commented Jun 19, 2023

I'm Sorry.
I'm trying to create a test file for replication, but it's not going well.
It seems like there are certain conditions that make it difficult.

@PanosKousidis
Copy link

PanosKousidis commented Jul 25, 2023

@rvdingDev, @appel1
I ran into the same issue and traced it down to the breaking change introduced in .NET 6: https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/partial-byte-reads-in-streams
The DeflateStream behaves differently now as it is more similar to the way the standard streams work.
I created the PR above that solves this issue - I wasn't able to produce a simple file with the problem, as the one I was using was pretty complex. But I think it happens when the sheet has a lot of data (my example had 81 rows 255 columns and it was only loading a few), due to the fact that the DeflateStream in BiffReader.cs returns less data than expected even if the stream is not finished

@appel1
Copy link
Collaborator

appel1 commented Jul 25, 2023

Thanks.

I thought I had fixed this as part of #621 but obviously it was not a complete fix.

Can ReadAtLeast be used here too?

@PanosKousidis
Copy link

Nice, it looks like you already addressed this issue but missed this bit. ReadAtLeast seems to be doing the job as well so that simplified the PR a lot

@appel1 appel1 added this to the 3.7 milestone Jul 25, 2023
@rvdingDev
Copy link
Author

@PanosKousidis,
Thank you for providing additional comments.

@rvdingDev rvdingDev reopened this Jul 26, 2023
@rvdingDev
Copy link
Author

I'm sorry. I pressed the wrong button.

@joydeep19
Copy link

joydeep19 commented Jul 26, 2023

Is this bug fixed,still I am facing this issue.

@appel1
Copy link
Collaborator

appel1 commented Jul 27, 2023

Is this bug fixed,still I am facing this issue.

No, not yet. Hopefully next week.

@joydeep19
Copy link

Can you let me know when this issue will resolve??

@stevie6410
Copy link

Hi, i've also just updated to .NET 7 from 5 and .xlsb is is broken for me too. v3.6.0 package.

Is there any workaround I can apply in the meantime?

@stevie6410
Copy link

Hi, I see the issue has been resolved and built. When does this package hit nuget as a pre-release?

@joydeep19
Copy link

When it will available in Nuget as a prerelease?

@rvdingDev
Copy link
Author

rvdingDev commented Aug 11, 2023

I'm also eagerly awaiting its prerelease on Nuget.

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

Successfully merging a pull request may close this issue.

5 participants