File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
ghcjs/delivery-calculator/src/App Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -18,14 +18,16 @@ newXlsx st imgs = xlsx
1818 xlsx =
1919 fromXlsx 0
2020 $ def
21- & atSheet " Delivery Calculator "
21+ & atSheet " Delivery_Calculator "
2222 ?~ sheet
2323 sheet =
2424 def
2525 & # wsDrawing
2626 .~ Just (Drawing mempty )
2727 & # wsRowPropertiesMap
2828 .~ newRowProps rows
29+ & # wsColumnsProperties
30+ .~ newColProps (fmap snd rows)
2931 & addHeader st
3032 & flip (foldl $ addRow imgs) rows
3133 rows =
@@ -43,10 +45,28 @@ newRowProps =
4345 . fmap
4446 ( \ (rowIdx, rowVal) ->
4547 if any (\ x -> x ^. # fieldType == FieldTypeImage ) rowVal
46- then Just (rowIdx, def & # rowHeight ?~ CustomHeight 200 )
48+ then Just (rowIdx, def & # rowHeight ?~ CustomHeight 180 )
4749 else Nothing
4850 )
4951
52+ newColProps :: [[Field DynamicField Unique ]] -> [ColumnsProperties ]
53+ newColProps rows = nubOrd $ do
54+ row <- rows
55+ (colIdx, colVal) <- zip [1 .. ] row
56+ if colVal ^. # fieldType /= FieldTypeImage
57+ then mempty
58+ else
59+ pure
60+ ColumnsProperties
61+ { cpMin = colIdx,
62+ cpMax = colIdx,
63+ cpWidth = Just 45 ,
64+ cpStyle = Nothing ,
65+ cpHidden = False ,
66+ cpCollapsed = False ,
67+ cpBestFit = False
68+ }
69+
5070addHeader :: St Unique -> Worksheet -> Worksheet
5171addHeader st sheet =
5272 case sortOn length headers of
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ data ColumnsProperties = ColumnsProperties
179179 -- fit'.
180180 cpBestFit :: Bool
181181 }
182- deriving (Eq , Show , Generic )
182+ deriving (Eq , Ord , Show , Generic )
183183
184184instance NFData ColumnsProperties
185185
You can’t perform that action at this time.
0 commit comments