Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion hledger-lib/Hledger/Reports/ReportOptions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ instance Default AccountListMode where def = ALFlat
data Layout = LayoutWide (Maybe Int)
| LayoutTall
| LayoutBare
| LayoutBareWide
| LayoutTidy
deriving (Eq, Show)

Expand Down Expand Up @@ -432,6 +433,7 @@ layoutopt rawopts = fromMaybe (LayoutWide Nothing) $ layout <|> column
, ("tall", LayoutTall)
, ("bare", LayoutBare)
, ("tidy", LayoutTidy)
, ("bare-wide", LayoutBareWide)
]
-- For `--layout=elided,n`, elide to the given width
(s,n) = break (==',') $ map toLower opt
Expand All @@ -440,7 +442,7 @@ layoutopt rawopts = fromMaybe (LayoutWide Nothing) $ layout <|> column
c | Just w' <- readMay c -> Just w'
_ -> usageError "width in --layout=wide,WIDTH must be an integer"

err = usageError "--layout's argument should be \"wide[,WIDTH]\", \"tall\", \"bare\", or \"tidy\""
err = usageError "--layout's argument should be \"wide[,WIDTH]\", \"tall\", \"bare\", \"bare-wide\", or \"tidy\""

-- Get the period specified by any -b/--begin, -e/--end and/or -p/--period
-- options appearing in the command line.
Expand Down
22 changes: 15 additions & 7 deletions hledger-lib/Hledger/Write/Spreadsheet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Hledger.Write.Spreadsheet (
horizontalSpan,
addHeaderBorders,
addRowSpanHeader,
addRowSpanHeaderNE,
rawTableContent,
cellFromMixedAmount,
cellsFromMixedAmount,
Expand All @@ -32,6 +33,8 @@ import Hledger.Data.Amount qualified as Amt
import Hledger.Data.Types (Amount, MixedAmount, acommodity)
import Hledger.Data.Amount (AmountFormat)

import Data.Foldable qualified as Fold
import Data.List.NonEmpty (NonEmpty((:|)))
import Data.List qualified as List
import Data.Text qualified as Text
import Data.Text (Text)
Expand Down Expand Up @@ -182,9 +185,9 @@ transpose :: [[Cell border text]] -> [[Cell border text]]
transpose = List.transpose . map (map transposeCell)


addHeaderBorders :: [Cell () text] -> [Cell NumLines text]
addHeaderBorders :: (Functor f) => f (Cell () text) -> f (Cell NumLines text)
addHeaderBorders =
map (\c -> c {cellBorder = noBorder {borderBottom = DoubleLine}})
fmap (\c -> c {cellBorder = noBorder {borderBottom = DoubleLine}})

horizontalSpan ::
(Lines border, Monoid text) =>
Expand All @@ -198,18 +201,23 @@ horizontalSpan subCells cell =
addRowSpanHeader ::
Cell border text ->
[[Cell border text]] -> [[Cell border text]]
addRowSpanHeader header rows =
addRowSpanHeader header = map Fold.toList . addRowSpanHeaderNE header

addRowSpanHeaderNE ::
Cell border text ->
[[Cell border text]] -> [NonEmpty (Cell border text)]
addRowSpanHeaderNE header rows =
case rows of
[] -> []
[row] -> [header:row]
[row] -> [header:|row]
_ ->
zipWith (:)
zipWith (:|)
(header{cellSpan = SpanVertical (length rows)} :
repeat header{cellSpan = Covered})
rows

rawTableContent :: [[Cell border text]] -> [[text]]
rawTableContent = map (map cellContent)
rawTableContent :: (Functor f) => [f (Cell border text)] -> [f text]
rawTableContent = map (fmap cellContent)



Expand Down
Loading