2
2
{-# LANGUAGE DeriveGeneric #-}
3
3
{-# LANGUAGE OverloadedStrings #-}
4
4
{-# LANGUAGE RecordWildCards #-}
5
- {-# LANGUAGE TemplateHaskell #-}
6
5
7
6
module Codec.Xlsx.Types.Cell
8
7
( CellFormula (.. ),
@@ -14,10 +13,6 @@ module Codec.Xlsx.Types.Cell
14
13
formulaDataFromCursor ,
15
14
applySharedFormulaOpts ,
16
15
Cell (.. ),
17
- cellStyle ,
18
- cellValue ,
19
- cellComment ,
20
- cellFormula ,
21
16
CellMap ,
22
17
)
23
18
where
@@ -49,14 +44,14 @@ import Text.XML.Cursor
49
44
--
50
45
-- See 18.3.1.40 "f (Formula)" (p. 1636)
51
46
data CellFormula = CellFormula
52
- { _cellfExpression :: FormulaExpression ,
47
+ { cellfExpression :: FormulaExpression ,
53
48
-- | Specifies that this formula assigns a value to a name.
54
- _cellfAssignsToName :: Bool ,
49
+ cellfAssignsToName :: Bool ,
55
50
-- | Indicates that this formula needs to be recalculated
56
51
-- the next time calculation is performed.
57
52
-- [/Example/: This is always set on volatile functions,
58
53
-- like =RAND(), and circular references. /end example/]
59
- _cellfCalculate :: Bool
54
+ cellfCalculate :: Bool
60
55
}
61
56
deriving (Eq , Show , Generic )
62
57
@@ -91,26 +86,26 @@ instance NFData SharedFormulaOptions
91
86
simpleCellFormula :: Text -> CellFormula
92
87
simpleCellFormula expr =
93
88
CellFormula
94
- { _cellfExpression = NormalFormula $ Formula expr,
95
- _cellfAssignsToName = False ,
96
- _cellfCalculate = False
89
+ { cellfExpression = NormalFormula $ Formula expr,
90
+ cellfAssignsToName = False ,
91
+ cellfCalculate = False
97
92
}
98
93
99
94
sharedFormulaByIndex :: SharedFormulaIndex -> CellFormula
100
95
sharedFormulaByIndex si =
101
96
CellFormula
102
- { _cellfExpression = SharedFormula si,
103
- _cellfAssignsToName = False ,
104
- _cellfCalculate = False
97
+ { cellfExpression = SharedFormula si,
98
+ cellfAssignsToName = False ,
99
+ cellfCalculate = False
105
100
}
106
101
107
102
-- | Currently cell details include cell values, style ids and cell
108
103
-- formulas (inline strings from @\<is\>@ subelements are ignored)
109
104
data Cell = Cell
110
- { _cellStyle :: Maybe Int ,
111
- _cellValue :: Maybe CellValue ,
112
- _cellComment :: Maybe Comment ,
113
- _cellFormula :: Maybe CellFormula
105
+ { cellStyle :: Maybe Int ,
106
+ cellValue :: Maybe CellValue ,
107
+ cellComment :: Maybe Comment ,
108
+ cellFormula :: Maybe CellFormula
114
109
}
115
110
deriving (Eq , Show , Generic )
116
111
@@ -119,8 +114,6 @@ instance NFData Cell
119
114
instance Default Cell where
120
115
def = Cell Nothing Nothing Nothing Nothing
121
116
122
- makeLenses ''Cell
123
-
124
117
-- | Map containing cell values which are indexed by row and column
125
118
-- if you need to use more traditional (x,y) indexing please you could
126
119
-- use corresponding accessors from ''Codec.Xlsx.Lens''
@@ -133,10 +126,10 @@ type CellMap = Map (RowIndex, ColumnIndex) Cell
133
126
formulaDataFromCursor ::
134
127
Cursor -> [(CellFormula , Maybe (SharedFormulaIndex , SharedFormulaOptions ))]
135
128
formulaDataFromCursor cur = do
136
- _cellfAssignsToName <- fromAttributeDef " bx" False cur
137
- _cellfCalculate <- fromAttributeDef " ca" False cur
129
+ cellfAssignsToName <- fromAttributeDef " bx" False cur
130
+ cellfCalculate <- fromAttributeDef " ca" False cur
138
131
t <- fromAttributeDef " t" defaultFormulaType cur
139
- (_cellfExpression , shared) <-
132
+ (cellfExpression , shared) <-
140
133
case t of
141
134
d | d == defaultFormulaType -> do
142
135
formula <- fromCursor cur
@@ -172,12 +165,12 @@ instance ToElement CellFormula where
172
165
commonAttrs =
173
166
M. fromList $
174
167
catMaybes
175
- [ " bx" .=? justTrue _cellfAssignsToName ,
176
- " ca" .=? justTrue _cellfCalculate ,
168
+ [ " bx" .=? justTrue cellfAssignsToName ,
169
+ " ca" .=? justTrue cellfCalculate ,
177
170
" t" .=? justNonDef defaultFormulaType fType
178
171
]
179
172
(formulaEl, fType) =
180
- case _cellfExpression of
173
+ case cellfExpression of
181
174
NormalFormula f -> (toElement nm f, defaultFormulaType)
182
175
SharedFormula si -> (leafElement nm [" si" .= si], " shared" )
183
176
0 commit comments