Mercurial > gemma
annotate pkg/xlsx/templater.go @ 5375:755ed195fdc3 extented-report
Fix for 5486:dbae10503ee6
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 24 Jun 2021 18:39:03 +0200 |
parents | 1adbd6a5f849 |
children | 699048c86848 |
rev | line source |
---|---|
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2021 by via donau |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package xlsx |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "bufio" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "context" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 "database/sql" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 "errors" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 "fmt" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 "io" |
5349
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
23 "log" |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 "os" |
5349
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
25 "strconv" |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 "strings" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 "github.com/360EntSecGroup-Skylar/excelize/v2" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 "gopkg.in/yaml.v2" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 "github.com/PaesslerAG/gval" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 ) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 type Action struct { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 Type string `yaml:"type"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 Actions []*Action `yaml:"actions"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 Location []string `yaml:"location"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 Source string `yaml:"source"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 Destination string `yaml:"destination"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 Statement string `yaml:"statement"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 Vars []string `yaml:"vars"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 Name string `yaml:"name"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 Expr string `yaml:"expr"` |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 type frame struct { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 res *sqlResult |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 index int |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
51 type sheetAxis struct { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
52 sheet string |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
53 axis string |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
54 } |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
55 |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
56 type cellValue struct { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
57 value string |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
58 err error |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
59 } |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
60 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 type executor struct { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 ctx context.Context |
5333
6c0f40676984
Run xlsx templating in a read-only transaction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5325
diff
changeset
|
63 tx *sql.Tx |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 template *excelize.File |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 keep map[string]bool |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 expressions map[string]gval.Evaluable |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 sourceSheet string |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 destinationSheet string |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 frames []frame |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
70 // Fetching formulas out of cells is very expensive so we cache them. |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
71 formulaCache map[sheetAxis]cellValue |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
74 type area struct { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
75 x1 int |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
76 y1 int |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
77 x2 int |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
78 y2 int |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
79 mc excelize.MergeCell |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
80 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
81 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
82 func mergeCellToArea(mc excelize.MergeCell) (area, error) { |
5346
72469b713705
XLSX templater: Cosmetics
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5344
diff
changeset
|
83 x1, y1, err := excelize.CellNameToCoordinates(mc.GetStartAxis()) |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
84 if err != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
85 return area{}, err |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
86 } |
5346
72469b713705
XLSX templater: Cosmetics
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5344
diff
changeset
|
87 x2, y2, err := excelize.CellNameToCoordinates(mc.GetEndAxis()) |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
88 if err != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
89 return area{}, err |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
90 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
91 return area{ |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
92 x1: x1, |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
93 y1: y1, |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
94 x2: x2, |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
95 y2: y2, |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
96 mc: mc, |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
97 }, nil |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
98 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
99 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
100 func (a *area) contains(x, y int) bool { |
5346
72469b713705
XLSX templater: Cosmetics
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5344
diff
changeset
|
101 return a.x1 <= x && x <= a.x2 && a.y1 <= y && y <= a.y2 |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
102 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
103 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 func ActionFromFile(filename string) (*Action, error) { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 f, err := os.Open(filename) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 return nil, err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 defer f.Close() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 return ActionFromReader(f) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 func ActionFromReader(r io.Reader) (*Action, error) { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 action := new(Action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 err := yaml.NewDecoder(bufio.NewReader(r)).Decode(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 return action, err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 func (a *Action) Execute( |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 ctx context.Context, |
5333
6c0f40676984
Run xlsx templating in a read-only transaction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5325
diff
changeset
|
121 tx *sql.Tx, |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 template *excelize.File, |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 ) error { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
125 //if f, err := os.Create("cpu.prof"); err == nil { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
126 // pprof.StartCPUProfile(f) |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
127 // defer pprof.StopCPUProfile() |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
128 //} |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
129 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 e := executor{ |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
131 ctx: ctx, |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
132 tx: tx, |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
133 template: template, |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
134 keep: map[string]bool{}, |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
135 expressions: map[string]gval.Evaluable{}, |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
136 formulaCache: map[sheetAxis]cellValue{}, |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 oldSheets := template.GetSheetList() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 if err := e.dispatch(a); err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 for _, sheet := range oldSheets { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 if !e.keep[sheet] { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 template.DeleteSheet(sheet) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 return nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
153 var reused int |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
154 |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
155 func (e *executor) getCellFormula(sheet, axis string) (string, error) { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
156 var ( |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
157 k = sheetAxis{sheet: sheet, axis: axis} |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
158 v cellValue |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
159 ok bool |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
160 ) |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
161 if v, ok = e.formulaCache[k]; !ok { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
162 v.value, v.err = e.template.GetCellFormula(sheet, axis) |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
163 e.formulaCache[k] = v |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
164 } |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
165 return v.value, v.err |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
166 } |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
167 |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
168 func (e *executor) setCellFormula(sheet, axis, formula string) { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
169 e.formulaCache[sheetAxis{sheet: sheet, axis: axis}] = cellValue{value: formula} |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
170 e.template.SetCellFormula(sheet, axis, formula) |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
171 } |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
172 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 func (e *executor) dispatch(action *Action) error { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 if len(action.Vars) > 0 { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 e.pushVars(action.Vars) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 defer e.popFrame() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 switch action.Type { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 case "sheet": |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 return e.sheet(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 case "copy": |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 return e.copy(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 case "select": |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 return e.sel(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 case "assign": |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 return e.assign(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 case "": |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 return e.actions(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 return fmt.Errorf("unknown type '%s'", action.Type) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 func (e *executor) pushVars(vars []string) { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 e.frames = append(e.frames, frame{ |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 res: &sqlResult{ |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 columns: vars, |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 rows: [][]interface{}{make([]interface{}, len(vars))}, |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 }, |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 }) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 func (e *executor) popFrame() { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 n := len(e.frames) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 e.frames[n-1].res = nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 e.frames = e.frames[:n-1] |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 func (e *executor) assign(action *Action) error { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 if action.Name == "" { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 return errors.New("missing name in assign") |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 if action.Expr == "" { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 return errors.New("missing expr in assign") |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 for i := len(e.frames) - 1; i >= 0; i-- { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 fr := &e.frames[i] |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 if idx := fr.res.find(action.Name); idx >= 0 { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 f, err := e.expr(action.Expr) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
222 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 value, err := f(e.ctx, e.vars()) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 fr.res.rows[fr.index][idx] = value |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 break |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
229 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
231 return e.actions(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
232 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
233 |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
234 func order(a, b int) (int, int) { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
235 if a < b { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
236 return a, b |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
237 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
238 return b, a |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
239 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
240 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 func (e *executor) copy(action *Action) error { |
5325
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
242 if n := len(action.Location); !(n == 1 || n == 2) { |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
243 return fmt.Errorf("length location = %d (expect 1 or 2)", |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
244 len(action.Location)) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 vars := e.vars() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 var err error |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 expand := func(s string) string { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 if err == nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 s, err = e.expand(s, vars) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
253 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 return s |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 split := func(s string) (int, int) { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 var x, y int |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 if err == nil { |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
259 x, y, err = excelize.CellNameToCoordinates(s) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 return x, y |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 |
5325
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
264 var location []string |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
265 if len(action.Location) == 1 { |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
266 location = []string{action.Location[0], action.Location[0]} |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
267 } else { |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
268 location = action.Location |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
269 } |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
270 |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
271 var destination string |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
272 if action.Destination == "" { |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
273 destination = location[0] |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
274 } else { |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
275 destination = action.Destination |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
276 } |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
277 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
278 var ( |
5325
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
279 s1 = expand(location[0]) |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
280 s2 = expand(location[1]) |
313bf3f3a8b1
XLSX templater: Simplify copy action.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5321
diff
changeset
|
281 d1 = expand(destination) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
282 sx1, sy1 = split(s1) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
283 sx2, sy2 = split(s2) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
284 dx1, dy1 = split(d1) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
285 ) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
286 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
287 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
288 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
289 sx1, sx2 = order(sx1, sx2) |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
290 sy1, sy2 = order(sy1, sy2) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
291 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
292 var areas []area |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
293 |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
294 //log.Println("merged cells") |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
295 if mcs, err := e.template.GetMergeCells(e.sourceSheet); err == nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
296 areas = make([]area, 0, len(mcs)) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
297 for _, mc := range mcs { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
298 if a, err := mergeCellToArea(mc); err == nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
299 areas = append(areas, a) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
300 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
301 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
302 } |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
303 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
304 for y, i := sy1, 0; y <= sy2; y, i = y+1, i+1 { |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
305 nextX: |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
306 for x, j := sx1, 0; x <= sx2; x, j = x+1, j+1 { |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
307 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
308 // check if cell is part of a merged cell |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
309 for k := range areas { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
310 area := &areas[k] |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
311 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
312 if area.contains(x, y) { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
313 ofsX := x - area.x1 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
314 ofsY := y - area.y1 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
315 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
316 sx := dx1 + j - ofsX |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
317 sy := dy1 + i - ofsY |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
318 ex := sx + (area.x2 - area.x1) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
319 ey := sy + (area.y2 - area.y1) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
320 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
321 // Copy over attributes |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
322 for l := 0; l <= area.x2-area.x1; l++ { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
323 for m := 0; m <= area.y2-area.y1; m++ { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
324 src, err1 := excelize.CoordinatesToCellName(area.x1+l, area.y1+m) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
325 dst, err2 := excelize.CoordinatesToCellName(sx+l, sy+m) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
326 if err1 != nil || err2 != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
327 continue |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
328 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
329 if s, err := e.template.GetCellStyle(e.sourceSheet, src); err == nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
330 e.template.SetCellStyle(e.destinationSheet, dst, dst, s) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
331 } |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
332 if s, err := e.getCellFormula(e.sourceSheet, src); err == nil { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
333 e.setCellFormula(e.destinationSheet, dst, s) |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
334 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
335 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
336 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
337 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
338 dst, err := excelize.CoordinatesToCellName(sx, sy) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
339 if err != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
340 continue nextX |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
341 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
342 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
343 // Copy over expanded text |
5354
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
344 if v, err := e.typedExpand(area.mc.GetCellValue(), vars); err == nil { |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
345 e.template.SetCellValue(e.destinationSheet, dst, v) |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
346 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
347 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
348 // Finally merge the cells |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
349 if end, err := excelize.CoordinatesToCellName(ex, ey); err == nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
350 e.template.MergeCell(e.destinationSheet, dst, end) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
351 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
352 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
353 continue nextX |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
354 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
355 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
356 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
357 // Regular cell |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
358 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
359 src, err := excelize.CoordinatesToCellName(x, y) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
360 if err != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
361 continue |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
362 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
363 dst, err := excelize.CoordinatesToCellName(dx1+j, dy1+i) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
364 if err != nil { |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
365 continue |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
366 } |
5343
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
367 |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
368 cn, err := excelize.ColumnNumberToName(x) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
369 if err != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
370 continue |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
371 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
372 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
373 cw, err := e.template.GetColWidth(e.sourceSheet, cn) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
374 if err != nil { |
5343
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
375 continue |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
376 } |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
377 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
378 rh, err := e.template.GetRowHeight(e.sourceSheet, y) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
379 if err != nil { |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
380 continue |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
381 } |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
382 |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
383 dc, err := excelize.ColumnNumberToName(dx1 + j) |
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
384 if err != nil { |
5343
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
385 continue |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
386 } |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
387 |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
388 if e.template.SetColWidth(e.destinationSheet, dc, dc, cw) != nil { |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
389 continue |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
390 } |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
391 |
5344
7df6062a1371
XLSX: Implemented correct handling of merged cells.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5343
diff
changeset
|
392 if e.template.SetRowHeight(e.destinationSheet, dy1+i, rh) != nil { |
5343
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
393 continue |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
394 } |
bb6761abd81d
XLSX template: Copy column and row height explicitly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5333
diff
changeset
|
395 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
396 if s, err := e.template.GetCellStyle(e.sourceSheet, src); err == nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
397 e.template.SetCellStyle(e.destinationSheet, dst, dst, s) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
398 } |
5364
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
399 if s, err := e.getCellFormula(e.sourceSheet, src); err == nil { |
1adbd6a5f849
XLSX templater: Cache cell formulas for performance.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5363
diff
changeset
|
400 e.setCellFormula(e.destinationSheet, dst, s) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
401 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
402 if s, err := e.template.GetCellValue(e.sourceSheet, src); err == nil { |
5362
f733bb327b9b
XLSX template: Fixed copy & paste errors from the toy tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5361
diff
changeset
|
403 if v, err := e.typedExpand(s, vars); err == nil { |
5354
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
404 e.template.SetCellValue(e.destinationSheet, dst, v) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
405 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
406 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
407 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
408 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
409 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
410 return nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
411 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
412 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
413 func (e *executor) sel(action *Action) error { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
414 vars := e.vars() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
415 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
416 eval := func(x string) (interface{}, error) { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
417 f, err := e.expr(x) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
418 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
419 return nil, err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
420 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
421 return f(e.ctx, vars) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
422 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
423 |
5333
6c0f40676984
Run xlsx templating in a read-only transaction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5325
diff
changeset
|
424 res, err := query(e.ctx, e.tx, action.Statement, eval) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
425 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
426 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
427 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
428 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
429 e.frames = append(e.frames, frame{res: res}) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
430 defer e.popFrame() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
431 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
432 for i := range res.rows { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
433 e.frames[len(e.frames)-1].index = i |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
434 if err := e.actions(action); err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
435 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
436 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
437 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
438 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
439 return nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
440 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
441 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
442 func (e *executor) actions(action *Action) error { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
443 for _, a := range action.Actions { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
444 if err := e.dispatch(a); err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
445 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
446 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
447 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
448 return nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
449 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
450 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
451 func (e *executor) sheet(action *Action) error { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
452 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
453 vars := e.vars() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
454 source, err := e.expand(action.Source, vars) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
455 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
456 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
457 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
458 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
459 srcIdx := e.template.GetSheetIndex(source) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
460 if srcIdx == -1 { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
461 return fmt.Errorf("sheet '%s' not found", source) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
462 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
463 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
464 destination := action.Destination |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
465 if destination == "" { // same as source |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
466 e.keep[source] = true |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
467 destination = source |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
468 } else { // new sheet |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
469 destination, err = e.expand(destination, vars) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
470 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
471 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
472 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
473 dstIdx := e.template.NewSheet(destination) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
474 if len(action.Actions) == 0 { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
475 // Only copy if there are no explicit instructions. |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
476 if err := e.template.CopySheet(srcIdx, dstIdx); err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
477 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
478 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
479 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
480 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
481 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
482 if len(action.Actions) > 0 { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
483 pSrc, pDst := e.sourceSheet, e.destinationSheet |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
484 defer func() { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
485 e.sourceSheet, e.destinationSheet = pSrc, pDst |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
486 }() |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
487 e.sourceSheet, e.destinationSheet = source, destination |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
488 return e.actions(action) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
489 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
490 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
491 // Simple filling |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
492 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
493 // "{{" only as a quick filter |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
494 result, err := e.template.SearchSheet(destination, "{{", true) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
495 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
496 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
497 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
498 for _, axis := range result { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
499 value, err := e.template.GetCellValue(destination, axis) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
500 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
501 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
502 } |
5362
f733bb327b9b
XLSX template: Fixed copy & paste errors from the toy tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5361
diff
changeset
|
503 nvalue, err := e.typedExpand(value, vars) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
504 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
505 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
506 } |
5362
f733bb327b9b
XLSX template: Fixed copy & paste errors from the toy tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5361
diff
changeset
|
507 if err := e.template.SetCellValue(destination, axis, nvalue); err != nil { |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
508 return err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
509 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
510 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
511 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
512 return nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
513 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
514 |
5349
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
515 func columnToNum(col interface{}) interface{} { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
516 var name string |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
517 switch v := col.(type) { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
518 case string: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
519 name = v |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
520 default: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
521 name = fmt.Sprintf("%v", col) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
522 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
523 num, err := excelize.ColumnNameToNumber(name) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
524 if err != nil { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
525 log.Printf("error: invalid column name '%v'\n", col) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
526 return 1 |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
527 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
528 return num |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
529 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
530 |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
531 func asInt(i interface{}) (int, error) { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
532 switch v := i.(type) { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
533 case int: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
534 return v, nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
535 case int8: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
536 return int(v), nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
537 case int16: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
538 return int(v), nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
539 case int32: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
540 return int(v), nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
541 case int64: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
542 return int(v), nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
543 case float32: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
544 return int(v), nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
545 case float64: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
546 return int(v), nil |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
547 case string: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
548 return strconv.Atoi(v) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
549 default: |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
550 return 0, fmt.Errorf("invalid int '%v'", i) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
551 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
552 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
553 |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
554 func coord2cell(ix, iy interface{}) interface{} { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
555 x, err := asInt(ix) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
556 if err != nil { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
557 log.Printf("error: invalid x value: %v\n", err) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
558 return "A1" |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
559 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
560 y, err := asInt(iy) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
561 if err != nil { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
562 log.Printf("error: invalid y value: %v\n", err) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
563 return "A1" |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
564 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
565 |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
566 cell, err := excelize.CoordinatesToCellName(x, y) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
567 if err != nil { |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
568 log.Printf("error: invalid cell coord (%d, %d)\n", x, y) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
569 return "A1" |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
570 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
571 return cell |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
572 } |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
573 |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
574 var templateLang = gval.Full( |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
575 gval.Function("column2num", columnToNum), |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
576 gval.Function("coord2cell", coord2cell), |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
577 ) |
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
578 |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
579 func (e *executor) expr(x string) (gval.Evaluable, error) { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
580 if f := e.expressions[x]; f != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
581 return f, nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
582 } |
5349
a352a695b69c
XLSX templater: Added column to coord conversions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5346
diff
changeset
|
583 f, err := templateLang.NewEvaluable(x) |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
584 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
585 return nil, err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
586 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
587 e.expressions[x] = f |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
588 return f, nil |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
589 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
590 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
591 func (e *executor) vars() map[string]interface{} { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
592 vars := map[string]interface{}{} |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
593 if len(e.frames) > 0 { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
594 vars["row_number"] = e.frames[len(e.frames)-1].index |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
595 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
596 for i := len(e.frames) - 1; i >= 0; i-- { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
597 fr := &e.frames[i] |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
598 for j, n := range fr.res.columns { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
599 if _, found := vars[n]; !found { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
600 vars[n] = fr.res.rows[fr.index][j] |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
601 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
602 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
603 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
604 return vars |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
605 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
606 |
5363
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
607 func (e *executor) expand( |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
608 str string, |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
609 vars map[string]interface{}, |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
610 ) (string, error) { |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
611 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
612 var err error |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
613 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
614 replace := func(s string) string { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
615 if err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
616 return "" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
617 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
618 var eval gval.Evaluable |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
619 if eval, err = e.expr(strings.TrimSpace(s)); err != nil { |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
620 return "" |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
621 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
622 s, err = eval.EvalString(e.ctx, vars) |
5362
f733bb327b9b
XLSX template: Fixed copy & paste errors from the toy tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5361
diff
changeset
|
623 if err != nil { |
f733bb327b9b
XLSX template: Fixed copy & paste errors from the toy tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5361
diff
changeset
|
624 log.Printf("error: '%s' '%s' %v\n", str, s, err) |
f733bb327b9b
XLSX template: Fixed copy & paste errors from the toy tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5361
diff
changeset
|
625 } |
5321
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
626 return s |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
627 } |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
628 |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
629 str = handlebars(str, replace) |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
630 return str, err |
0919946f624b
Added a report controller.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
631 } |
5354
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
632 |
5363
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
633 func (e *executor) typedExpand( |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
634 str string, |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
635 vars map[string]interface{}, |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
636 ) (interface{}, error) { |
5354
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
637 |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
638 var ( |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
639 err error |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
640 repCount int |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
641 last interface{} |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
642 ) |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
643 |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
644 replace := func(s string) string { |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
645 if err != nil { |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
646 return "" |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
647 } |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
648 var eval gval.Evaluable |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
649 if eval, err = e.expr(strings.TrimSpace(s)); err != nil { |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
650 return "" |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
651 } |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
652 repCount++ |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
653 last, err = eval(e.ctx, vars) |
5363
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
654 if err != nil { |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
655 log.Printf("error: '%s' '%s' %v\n", str, s, err) |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
656 } |
5354
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
657 return fmt.Sprintf("%v", last) |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
658 } |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
659 |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
660 nstr := handlebars(str, replace) |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
661 |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
662 if err != nil { |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
663 return nil, err |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
664 } |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
665 |
5363
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
666 if repCount == 1 && |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
667 strings.HasPrefix(str, "{{") && |
04b3fb35910c
XLSX templater: More logging in case of expression eval errors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5362
diff
changeset
|
668 strings.HasSuffix(str, "}}") { |
5354
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
669 return last, nil |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
670 } |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
671 return nstr, nil |
6a94ab82eaaa
XLSX templater: Added type support for cell expansion.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5349
diff
changeset
|
672 } |