Skip to content

Commit e328ac6

Browse files
committed
fix excel compatibility for images
1 parent 2bc83ee commit e328ac6

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

ghcjs/delivery-calculator/delivery-calculator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: delivery-calculator
3-
version: 0.1.0.1
3+
version: 0.1.0.2
44
synopsis: Delivery Calculator
55
category: Web
66
build-type: Simple

ghcjs/delivery-calculator/src/App/Xlsx.hs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ newXlsx st imgs = xlsx
1818
xlsx =
1919
fromXlsx 0
2020
$ def
21-
& #xlStyles
22-
.~ renderStyleSheet style
23-
& atSheet "Delivery_Calculator"
21+
& atSheet "Delivery Calculator"
2422
?~ sheet
2523
sheet =
2624
def
@@ -70,18 +68,6 @@ newColProps rows = nubOrd $ do
7068
cpBestFit = False
7169
}
7270

73-
style :: StyleSheet
74-
style =
75-
def
76-
& #styleSheetCellXfs
77-
.~ [ def
78-
& #cellXfAlignment
79-
?~ ( def
80-
& #_alignmentVertical
81-
?~ CellVerticalAlignmentCenter
82-
)
83-
]
84-
8571
addHeader :: St Unique -> Worksheet -> Worksheet
8672
addHeader st sheet =
8773
case sortOn length headers of
@@ -173,7 +159,7 @@ addCol imgs sheet rowIdx colIdx field =
173159
. _Just
174160
%~ \case
175161
Drawing xs ->
176-
Drawing $ newImg rowIdx colIdx (length xs) img : xs
162+
Drawing $ newImg rowIdx colIdx (length xs + 1) img : xs
177163
where
178164
txt = field ^. #fieldInput . #uniqueValue
179165

@@ -190,12 +176,19 @@ newImg (RowIndex rowIdx) (ColumnIndex colIdx) imgIdx rfc2397 =
190176
anchClientData = def
191177
}
192178
where
179+
mime = decodeUtf8 $ rfc2397Mime rfc2397
180+
ext =
181+
from @Text @String
182+
. maybe mempty ("." <>)
183+
. safeHead
184+
. reverse
185+
$ splitWhen (== '/') mime
193186
obj =
194187
picture
195188
(DrawingElementId imgIdx)
196189
FileInfo
197-
{ fiFilename = "img",
198-
fiContentType = decodeUtf8 $ rfc2397Mime rfc2397,
190+
{ fiFilename = "image" <> inspect imgIdx <> ext,
191+
fiContentType = mime,
199192
fiContents = rfc2397Bytes rfc2397
200193
}
201194

ghcjs/delivery-calculator/trapeze.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
platforms:
22
android:
33
appName: Delivery Calculator
4-
versionCode: 1
5-
versionName: 0.1.0.1
4+
versionCode: 2
5+
versionName: 0.1.0.2
66
packageName: com.functora.delivery_calculator
77
manifest:
88
- file: AndroidManifest.xml

nix/configuration.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ in {
563563
xorg.xev
564564
yewtube
565565
niv
566+
zip
566567
unzip
567568
pciutils
568569
docker-compose

pub/xlsx/src/Codec/Xlsx/Types/Drawing.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ picture dId fi =
139139
shProps =
140140
ShapeProperties
141141
{ spXfrm = Nothing,
142-
spGeometry = Nothing,
142+
spGeometry = Just PresetGeometry,
143143
spFill = Just NoFill,
144144
spOutline = Just $ def {_lnFill = Just NoFill}
145145
}

0 commit comments

Comments
 (0)