-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix: Add OpenReader options to GetRows #1816
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the OpenReader
options are not used in the GetRows
function, the GetRows
function just uses the same data structure Options
as the OpenReader
function to specify the RawCellValue
. I agree with making the cell value reading functions inherit the Options
settings of the OpenReader
function, and we need to consider following 2 conditions:
- If
Options
have also been passed when calling the cell value reading functions, its priority should be higher thanOpenReader
and override its settings, so the code needs to be changed to:
-opts = append(opts, *f.options)
+opts = append([]Options{*rows.f.options}, opts...)
- The following cell reading functions also need to inherit the Options settings:
Based on the above two points, to avoid append options duplicated, I suggest changing the getOptions
function to support inheriting the Options
settings of the OpenReader
function, just like this:
-func getOptions(opts ...Options) *Options {
- options := &Options{}
+func (f *File) getOptions(opts ...Options) *Options {
+ options := f.options
- The unit tests covered these changes
I've done the code changes, the current tests are passing. Could you guide me through the unit tests once? |
Fixed, also removed multiple times options fetch in CalcCellValue |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1816 +/- ##
=======================================
Coverage 99.20% 99.20%
=======================================
Files 32 32
Lines 23851 23852 +1
=======================================
+ Hits 23662 23663 +1
Misses 101 101
Partials 88 88
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your contribution.
Hey @xuri I am using v2 version of excelize, do I need to send a separate PR for that? |
The next version will be released based on the master branch. You can upgrade to the master branch code by |
PR Details
The Options struct passed to OpenReader function is not passed in the GetRows which results in passing the options separately resulting in duplication
Description
Passing Options to OpenReader should automatically pass the same Options in the child function call as it is done initially. Currently the OpenReader options are not used in GetRows function, which causes inconsistency and leads to duplication.
Related Issue
#1815
Motivation and Context
It solves the duplicate need of passing Options if it's already passed in OpenReader
How Has This Been Tested
Tested locally on my machine with multiple excel files and the output it gives satisfies the requirement
Types of changes
Checklist