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

The implementation of the important function "SEARCHB" is missing from this project. #1647

Closed
godsmell opened this issue Sep 4, 2023 · 2 comments
Labels
bug Something isn't working confirmed This issue can be reproduced

Comments

@godsmell
Copy link

godsmell commented Sep 4, 2023

Description
The implementation of the important function "SEARCHB" is missing from this project.

Describe the results you expected:
获取到螺钉编号为: 1020

func Test2MyTest(t *testing.T) {
	f, err := excelize.OpenFile("../test.xlsx")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer f.Close()

	f.SetCellValue("Sheet1", "A1", "螺钉1020")
	f.SetCellFormula("Sheet1", "B1", `MIDB(A1,SEARCHB("?",A1),2*LEN(A1)-LENB(A1))`)
	if foo, err := f.CalcCellValue("Sheet1", "B1"); err == nil {
		fmt.Println("获取到螺钉编号为:", foo)
	} else {
		fmt.Println("ERROR:", err)
	}
}

Describe the results you received:

Running tool: C:\golang\go\bin\go.exe test -timeout 30s -run ^Test2MyTest$ excelizer/testing -v

=== RUN   Test2MyTest
--- FAIL: Test2MyTest (0.00s)
panic: runtime error: slice bounds out of range [-1:] [recovered]
	panic: runtime error: slice bounds out of range [-1:]

goroutine 21 [running]:
testing.tRunner.func1.2({0x7a6800, 0xc0000140d8})
	C:/golang/go/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	C:/golang/go/src/testing/testing.go:1392 +0x39f
panic({0x7a6800, 0xc0000140d8})
	C:/golang/go/src/runtime/panic.go:838 +0x207
github.com/xuri/excelize/v2.(*formulaFuncs).mid(0xc000020410?, {0x7cf338, 0x4}, 0xc0004423a8?)
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:13796 +0xa18
github.com/xuri/excelize/v2.(*formulaFuncs).MIDB(0xc0000981e0?, 0x2?)
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:13766 +0x67
reflect.Value.call({0x7cb7c0?, 0xc00001ec90?, 0x106?}, {0x7cf124, 0x4}, {0xc000442e20, 0x1, 0x895040?})
	C:/golang/go/src/reflect/value.go:556 +0x845
reflect.Value.Call({0x7cb7c0?, 0xc00001ec90?, 0x0?}, {0xc000442e20, 0x1, 0x1})
	C:/golang/go/src/reflect/value.go:339 +0xbf
github.com/xuri/excelize/v2.callFuncByName({0x7cb7c0?, 0xc00001ec90?}, {0xc00001216c, 0x0?}, {0xc000442e20, 0x1, 0x1})
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:1685 +0x150
github.com/xuri/excelize/v2.(*File).evalInfixExpFunc(_, _, {_, _}, {_, _}, {{0x0, 0x0}, {0x7d5e6a, 0x8}, ...}, ...)
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:1053 +0x4dd
github.com/xuri/excelize/v2.(*File).evalInfixExp(0xc000085d40?, 0xc00040e990?, {0x7d23b2, 0x6}, {0x7cd9ce, 0x2}, {0xc0003af000, 0x13, 0x13?})
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:1028 +0x1a39
github.com/xuri/excelize/v2.(*File).calcCellValue(0x0?, 0x0?, {0x7d23b2, 0x6}, {0x7cd9ce, 0x2})
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:844 +0x1b1
github.com/xuri/excelize/v2.(*File).CalcCellValue(0xc000085d40?, {0x7d23b2, 0x6}, {0x7cd9ce, 0x2}, {0x0, 0x0, 0x0?})
	C:/golang/gopath/pkg/mod/github.com/xuri/excelize/v2@v2.8.0/calc.go:807 +0x2f7
excelizer/testing.Test2MyTest(0x0?)
	d:/DEV/go-dev/excelizer/testing/excel_test.go:189 +0x15e
testing.tRunner(0xc000085a00, 0x801cc0)
	C:/golang/go/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
	C:/golang/go/src/testing/testing.go:1486 +0x35f
FAIL	excelizer/testing	0.331s

Can you provide the implementation of the function SEARCHB?

Environment details (OS, Microsoft Excel™ version, physical, etc.):

@xuri xuri added bug Something isn't working confirmed This issue can be reproduced labels Sep 5, 2023
@godsmell
Copy link
Author

godsmell commented Sep 6, 2023

Thanks a lot !

@xuri xuri added the in progress Working in progress label Sep 7, 2023
@xuri xuri closed this as completed in 5e8a020 Sep 7, 2023
@xuri
Copy link
Member

xuri commented Sep 7, 2023

Thanks for your issue. I have fixed this issue, please try to upgrade the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Sep 7, 2023
xuri added a commit that referenced this issue Sep 7, 2023
- Correction cell type when formatting date type cell value
- Add check for MID and MIDB formula functions num_chars arguments, prevent panic on specifying a negative number
- Ref #65, add support for 2 formula functions: SEARCH and SEARCHB
- Fix a v2.8.0 regression bug, error on set print area and print titles with built-in special defined name
- Add new exported function `GetPivotTables` for get pivot tables
- Add a new `Name` field in the `PivotTableOptions` to support specify pivot table name
- Using relative cell reference in the pivot table docs and unit tests
- Support adding slicer content type part internally
- Add new exported source relationship and namespace `NameSpaceSpreadSheetXR10`, `ContentTypeSlicer`, `ContentTypeSlicerCache`, and `SourceRelationshipSlicer`
- Add new exported extended URI `ExtURIPivotCacheDefinition`
- Fix formula argument wildcard match issues
- Update GitHub Actions configuration, test on Go 1.21.x with 1.21.1 and later
- Avoid corrupted workbooks generated by improving compatibility with internally indexed color styles
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Correction cell type when formatting date type cell value
- Add check for MID and MIDB formula functions num_chars arguments, prevent panic on specifying a negative number
- Ref qax-os#65, add support for 2 formula functions: SEARCH and SEARCHB
- Fix a v2.8.0 regression bug, error on set print area and print titles with built-in special defined name
- Add new exported function `GetPivotTables` for get pivot tables
- Add a new `Name` field in the `PivotTableOptions` to support specify pivot table name
- Using relative cell reference in the pivot table docs and unit tests
- Support adding slicer content type part internally
- Add new exported source relationship and namespace `NameSpaceSpreadSheetXR10`, `ContentTypeSlicer`, `ContentTypeSlicerCache`, and `SourceRelationshipSlicer`
- Add new exported extended URI `ExtURIPivotCacheDefinition`
- Fix formula argument wildcard match issues
- Update GitHub Actions configuration, test on Go 1.21.x with 1.21.1 and later
- Avoid corrupted workbooks generated by improving compatibility with internally indexed color styles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants