@@ -7,6 +7,90 @@ import (
77 "testing"
88)
99
10+ func TestXlRange_Find (t * testing.T ) {
11+ quit := MustInitGoxcel ()
12+ defer quit ()
13+
14+ excel , release := MustNewGoxcel ()
15+ defer release ()
16+
17+ wbs := excel .MustWorkbooks ()
18+ wb , wbr := wbs .MustAdd ()
19+ defer wbr ()
20+
21+ ws := wb .MustSheets (1 )
22+
23+ rows := []int {1 , 2 , 3 , 4 , 5 }
24+ for _ , row := range rows {
25+ cols := []int {1 , 2 , 3 , 4 , 5 }
26+ for _ , col := range cols {
27+ c , _ := ws .Cells (row , col )
28+ c .MustSetValue (fmt .Sprintf ("%v,%v" , row , col ))
29+ }
30+ }
31+
32+ //
33+ // Range.Find
34+ //
35+ rng , _ := ws .UsedRange ()
36+ after , _ := rng .Cells (1 , 1 )
37+ foundRange , found , err := rng .Find ("1," , after )
38+ if err != nil {
39+ t .Fatal (err )
40+ }
41+
42+ if ! found {
43+ t .Fatalf ("expected range to be found, got nothing" )
44+ }
45+
46+ value , err := foundRange .Value ()
47+ if err != nil {
48+ t .Fatal (err )
49+ }
50+
51+ t .Log (value )
52+
53+ //
54+ // Range.FindNext
55+ //
56+ after , _ = foundRange .Cells (1 , 1 )
57+ foundRange , found , err = rng .FindNext (after )
58+ if err != nil {
59+ t .Fatal (err )
60+ }
61+
62+ if ! found {
63+ t .Fatalf ("expected range to be found, got nothing 2" )
64+ }
65+
66+ value , err = foundRange .Value ()
67+ if err != nil {
68+ t .Fatal (err )
69+ }
70+
71+ t .Log (value )
72+
73+ //
74+ // Range.FindPrevious
75+ //
76+ before , _ := foundRange .Cells (1 , 1 )
77+ foundRange , found , err = rng .FindPrevious (before )
78+ if err != nil {
79+ t .Fatal (err )
80+ }
81+
82+ if ! found {
83+ t .Fatalf ("expected range to be found, got nothing 3" )
84+ }
85+
86+ value , err = foundRange .Value ()
87+ if err != nil {
88+ t .Fatal (err )
89+ }
90+
91+ t .Log (value )
92+ }
93+
1094func TestXlRange_CopyPicture (t * testing.T ) {
1195 quit := MustInitGoxcel ()
1296 defer quit ()
0 commit comments