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
GetSheetIndex and CopySheet bug #1617
Comments
Thanks for your issue. As the documentation of the +from, err := xlsx.GetSheetIndex("Sheet1")
+checkError(err)
+err = xlsx.CopySheet(from, index)
-err = xlsx.CopySheet(1, index) |
Thanks for the classification. I didn't notice the difference between "sheet ID" and "sheet index". |
Hi @xuri and other contributors, I tried to copy "Sheet1" in a .xlsx file, but it reported
Reproducible data (t.xlsx, created with this excellent package) and code:
The version v2.7.1 (even v2.6.1) and the master branch of
excelize
can both reproduce this result.After checking the source code of
excelize
, I found the direct bug is thatGetSheetIndex
returns a 0-based index, which was called inNewSheet
and other methods.In
GetSheetIndex
methods, the methodGetSheetList
was called (returned index is 0-based!!!), which should beGetSheetMap
, so did other methods.I forked this package and replaced
GetSheetList
withGetSheetMap
; the test code above could pass, but some other tests failed withgo test .
. It looks like much effort needs to be taken from more experienced authors.BTW,
SetActiveSheet
seems to use another type of index, where0
is allowed. The doc is not clear to me, could you please add more details?The text was updated successfully, but these errors were encountered: