Skip to content

Commit

Permalink
Fix all but 3 test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeTemp committed Aug 31, 2022
1 parent ea1616b commit 1d1256d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Codec/Xlsx/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ textToColumnIndex = ColumnIndex . T.foldl' (\i c -> i * 26 + let2int c) 0
where
let2int c = 1 + ord c - ord 'A'

textToRowIndex :: Text -> RowIndex
textToRowIndex = RowIndex . read . T.unpack

-- | Excel cell or cell range reference (e.g. @E3@), possibly absolute.
-- See 18.18.62 @ST_Ref@ (p. 2482)
--
Expand Down Expand Up @@ -173,7 +176,7 @@ coord2row (RowRel c) = rowIndexToText c
row2coord :: Text -> RowCoord
row2coord t =
let t' = T.stripPrefix "$" t
in mkRowCoord (isJust t') . read . T.unpack $ fromMaybe t t'
in mkRowCoord (isJust t') (textToRowIndex (fromMaybe t t'))

-- | Unwrap a Coord into an abstract Int coordinate
unRowCoord :: RowCoord -> RowIndex
Expand Down Expand Up @@ -204,7 +207,7 @@ singleCellRef' :: CellCoord -> CellRef
singleCellRef' = CellRef . singleCellRefRaw'

singleCellRefRaw :: (RowIndex, ColumnIndex) -> Text
singleCellRefRaw (row, col) = T.concat [columnIndexToText col, T.pack (show row)]
singleCellRefRaw (row, col) = T.concat [columnIndexToText col, rowIndexToText row]

singleCellRefRaw' :: CellCoord -> Text
singleCellRefRaw' (row, col) =
Expand Down
3 changes: 2 additions & 1 deletion src/Codec/Xlsx/Types/Internal/CommentTable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ renderShapes (CommentTable m) = LB.concat
, "<v:path gradientshapeok=\"t\" o:connecttype=\"rect\"></v:path>"
, "</v:shapetype>"
]
fromRef = fromJustNote "Invalid comment ref" . fromSingleCellRef
fromRef cr =
fromJustNote ("Invalid comment ref: " <> show cr) $ fromSingleCellRef cr
commentShapes = [ commentShape (fromRef ref) (_commentVisible cmnt)
| (ref, cmnt) <- M.toList m ]
commentShape (r, c) v = LB.concat
Expand Down

0 comments on commit 1d1256d

Please sign in to comment.