question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make ResetSheetData method public

See original GitHub issue

In version 3.0 you’re added the IExcelDataReader.Reset method, which resets reader to the beginning of workbook.

In our project, we often need to reset a worksheet, not a whole workbook reading state. So, I propose to make ResetSheetData method public and add it to the IExcelDataReader interface (currently, ResetSheetData is owned by ExcelDataReader abstract class. Or, maybe overloaded Reset method is enough (like reader.Reset(worksheet: true)).

Now, we are using reflection to emulate that behavior:

image

^ look at the dictionary, base type for the ExcelBinaryReader is not same as base type of the ExcelOpenXmlReader.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
andersnmcommented, Nov 19, 2019

Hi,

I share @appel1’s concerns, and would have tested the reflection based approach myself provided the actual code rather than a screenshot 😃 The proposed solution with Reset() and NextResult() should be both safe and performant, because previously read worksheet metadata are cached internally in the reader. Only (minor) drawback is it requires a sheet index to reset to.

This is a valid feature request however, and adding new ResetResult() method or something makes sense for use cases like this.

0reactions
appel1commented, Nov 18, 2019

ResetSheetData works the same way in 3.6.0 as it does in head of develop so then I don’t see how it could possible do what you describe. Are you perhaps checking the Depth property to determine what row you are reading? Calling ResetSheetData will make Depth start over from 0 but will not actually make Read start over from the first row of the current sheet. https://github.com/ExcelDataReader/ExcelDataReader/blob/e5b7d41b580603c866b9097496139080c0bba105/src/ExcelDataReader/ExcelDataReader.cs#L295-L299

What do you think about the solution I posted here? Any reason that doesn’t work for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get only public methods of a class using Java reflection
For example, I have a private getNode method that, while the "modifiers" value appears as 2 in the debugger, it outputs as "1"...
Read more >
Google Apps Script, Sheets, Cloud and Automation
There is a simple way to reset sheet data. ... Create google sheets with specific name of column , share the file to...
Read more >
C# (CSharp) IEnumerator.Dispose Examples
In this example, we implement the IEnumerator and IDisposable interfaces to create a custom enumerator. The Dispose method simply writes to the console...
Read more >
Uipath Convert Excel To Pdf
NET offers a method to convert Excel to PDF, I. You can read and separately extract the content of. UiPath Extract PDF Text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found