hledger-lib-1.50.3: A library providing the core functionality of hledger

Safe Haskell | None
Language | GHC2021

Hledger.Write.Spreadsheet

Description

Rich data type to describe data in a table. This is the basis for ODS and HTML export.

Synopsis

- data Type
  - = TypeString
  - | TypeInteger
  - | TypeAmount !Amount
  - | TypeMixedAmount
  - | TypeDate
- data Style
  - = Body Emphasis
  - | Head
- data Emphasis
  - = Item
  - | Total
- data Cell border text = Cell {
  - cellType :: Type
  - cellBorder :: Border border
  - cellStyle :: Style
  - cellSpan :: Span
  - cellAnchor :: Text
  - cellClass :: Class
  - cellContent :: text
  }
- newtype Class = Class Text
- textFromClass :: Class -> Text
- data Span
  - = NoSpan
  - | Covered
  - | SpanHorizontal Int
  - | SpanVertical Int
- data Border lines = Border {
  - borderLeft :: lines
  - borderRight :: lines
  - borderTop :: lines
  - borderBottom :: lines
  }
- class Lines border where
  - noLine :: border
- data NumLines
  - = NoLine
  - | SingleLine
  - | DoubleLine
- noBorder :: Lines border => Border border
- defaultCell :: Lines border => text -> Cell border text
- headerCell :: Lines borders => Text -> Cell borders Text
- emptyCell :: (Lines border, Monoid text) => Cell border text
- transposeCell :: Cell border text -> Cell border text
- transpose :: [[Cell border text]] -> [[Cell border text]]
- horizontalSpan :: (Lines border, Monoid text) => [a] -> Cell border text -> [Cell border text]
- addHeaderBorders :: [Cell () text] -> [Cell NumLines text]
- addRowSpanHeader :: Cell border text -> [[Cell border text]] -> [[Cell border text]]
- rawTableContent :: [[Cell border text]] -> [[text]]
- cellFromMixedAmount :: Lines border => AmountFormat -> (Class, MixedAmount) -> Cell border WideBuilder
- cellsFromMixedAmount :: Lines border => AmountFormat -> (Class, MixedAmount) -> [Cell border WideBuilder]
- cellFromAmount :: Lines border => AmountFormat -> (Class, (wb, Amount)) -> Cell border wb
- integerCell :: Lines border => Integer -> Cell border Text

# Documentation

data Type Source #

Constructors

TypeString |
TypeInteger |
TypeAmount !Amount |
TypeMixedAmount |
TypeDate |

#### Instances

Instances details

Show Type Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods showsPrec :: Int -> Type -> ShowS Source # show :: Type -> String Source # showList :: [Type] -> ShowS Source #
Eq Type Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Type -> Type -> Bool Source # (/=) :: Type -> Type -> Bool Source #
Ord Type Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods compare :: Type -> Type -> Ordering Source # (<) :: Type -> Type -> Bool Source # (<=) :: Type -> Type -> Bool Source # (>) :: Type -> Type -> Bool Source # (>=) :: Type -> Type -> Bool Source # max :: Type -> Type -> Type Source # min :: Type -> Type -> Type Source #

data Style Source #

Constructors

Body Emphasis |
Head |

#### Instances

Instances details

Show Style Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods showsPrec :: Int -> Style -> ShowS Source # show :: Style -> String Source # showList :: [Style] -> ShowS Source #
Eq Style Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Style -> Style -> Bool Source # (/=) :: Style -> Style -> Bool Source #
Ord Style Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods compare :: Style -> Style -> Ordering Source # (<) :: Style -> Style -> Bool Source # (<=) :: Style -> Style -> Bool Source # (>) :: Style -> Style -> Bool Source # (>=) :: Style -> Style -> Bool Source # max :: Style -> Style -> Style Source # min :: Style -> Style -> Style Source #

data Emphasis Source #

Constructors

Item |
Total |

#### Instances

Instances details

Show Emphasis Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods showsPrec :: Int -> Emphasis -> ShowS Source # show :: Emphasis -> String Source # showList :: [Emphasis] -> ShowS Source #
Eq Emphasis Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Emphasis -> Emphasis -> Bool Source # (/=) :: Emphasis -> Emphasis -> Bool Source #
Ord Emphasis Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods compare :: Emphasis -> Emphasis -> Ordering Source # (<) :: Emphasis -> Emphasis -> Bool Source # (<=) :: Emphasis -> Emphasis -> Bool Source # (>) :: Emphasis -> Emphasis -> Bool Source # (>=) :: Emphasis -> Emphasis -> Bool Source # max :: Emphasis -> Emphasis -> Emphasis Source # min :: Emphasis -> Emphasis -> Emphasis Source #

data Cell border text Source #

Constructors

Cell |

Fields

- cellType :: Type
- cellBorder :: Border border
- cellStyle :: Style
- cellSpan :: Span
- cellAnchor :: Text
- cellClass :: Class
- cellContent :: text

#### Instances

Instances details

Functor (Cell border) Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods fmap :: (a -> b) -> Cell border a -> Cell border b Source # (<$) :: a -> Cell border b -> Cell border a Source #

newtype Class Source #

Constructors

Class Text |

textFromClass :: Class -> Text Source #

data Span Source #

- `NoSpan` means a single unmerged cell.
- `Covered` is a cell if it is part of a horizontally or vertically merged cell. We maintain these cells although they are ignored in HTML output. In contrast to that, FODS can store covered cells and allows to access the hidden cell content via formulas. CSV does not support merged cells and thus simply writes the content of covered cells. Maintaining `Covered` cells also simplifies transposing.
- ``SpanHorizontal` n` denotes the first cell in a row that is part of a merged cell. The merged cell contains `n` atomic cells, including the first one. That is `SpanHorizontal 1` is actually like `NoSpan`. The content of this cell is shown as content of the merged cell.
- ``SpanVertical` n` starts a vertically merged cell.

The writer functions expect consistent data, that is, `Covered` cells must actually be part of a merged cell and merged cells must only cover `Covered` cells.

Constructors

NoSpan |
Covered |
SpanHorizontal Int |
SpanVertical Int |

#### Instances

Instances details

Eq Span Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Span -> Span -> Bool Source # (/=) :: Span -> Span -> Bool Source #

data Border lines Source #

Constructors

Border |

Fields

- borderLeft :: lines
- borderRight :: lines
- borderTop :: lines
- borderBottom :: lines

#### Instances

Instances details

Applicative Border Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods pure :: a -> Border a Source # (<*>) :: Border (a -> b) -> Border a -> Border b Source # liftA2 :: (a -> b -> c) -> Border a -> Border b -> Border c Source # (*>) :: Border a -> Border b -> Border b Source # (<*) :: Border a -> Border b -> Border a Source #
Functor Border Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods fmap :: (a -> b) -> Border a -> Border b Source # (<$) :: a -> Border b -> Border a Source #
Foldable Border Source # |

Instance details

Defined in Hledger.Write.Spreadsheet

Methods

fold :: Monoid m => Border m -> m Source #

foldMap :: Monoid m => (a -> m) -> Border a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Border a -> m Source #

foldr :: (a -> b -> b) -> b -> Border a -> b Source #

foldr' :: (a -> b -> b) -> b -> Border a -> b Source #

foldl :: (b -> a -> b) -> b -> Border a -> b Source #

foldl' :: (b -> a -> b) -> b -> Border a -> b Source #

foldr1 :: (a -> a -> a) -> Border a -> a Source #

foldl1 :: (a -> a -> a) -> Border a -> a Source #

toList :: Border a -> [a] Source #

null :: Border a -> Bool Source #

length :: Border a -> Int Source #

elem :: Eq a => a -> Border a -> Bool Source #

maximum :: Ord a => Border a -> a Source #

minimum :: Ord a => Border a -> a Source #

sum :: Num a => Border a -> a Source #

product :: Num a => Border a -> a Source #

Show lines => Show (Border lines) Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods showsPrec :: Int -> Border lines -> ShowS Source # show :: Border lines -> String Source # showList :: [Border lines] -> ShowS Source #
Eq lines => Eq (Border lines) Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Border lines -> Border lines -> Bool Source # (/=) :: Border lines -> Border lines -> Bool Source #
Ord lines => Ord (Border lines) Source # |

Instance details

Defined in Hledger.Write.Spreadsheet

Methods

compare :: Border lines -> Border lines -> Ordering Source #

(<) :: Border lines -> Border lines -> Bool Source #

(<=) :: Border lines -> Border lines -> Bool Source #

(>) :: Border lines -> Border lines -> Bool Source #

(>=) :: Border lines -> Border lines -> Bool Source #

max :: Border lines -> Border lines -> Border lines Source #

min :: Border lines -> Border lines -> Border lines Source #

class Lines border where Source #

Methods

noLine :: border Source #

#### Instances

Instances details

Lines NumLines Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods noLine :: NumLines Source #
Lines () Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods noLine :: () Source #

data NumLines Source #

The same as Tab.Properties, but has `Eq` and `Ord` instances. We need those for storing `NumLines` in `Set`s.

Constructors

NoLine |
SingleLine |
DoubleLine |

#### Instances

Instances details

Show NumLines Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods showsPrec :: Int -> NumLines -> ShowS Source # show :: NumLines -> String Source # showList :: [NumLines] -> ShowS Source #
Eq NumLines Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: NumLines -> NumLines -> Bool Source # (/=) :: NumLines -> NumLines -> Bool Source #
Ord NumLines Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods compare :: NumLines -> NumLines -> Ordering Source # (<) :: NumLines -> NumLines -> Bool Source # (<=) :: NumLines -> NumLines -> Bool Source # (>) :: NumLines -> NumLines -> Bool Source # (>=) :: NumLines -> NumLines -> Bool Source # max :: NumLines -> NumLines -> NumLines Source # min :: NumLines -> NumLines -> NumLines Source #
Lines NumLines Source # |
Instance details Defined in Hledger.Write.Html.HtmlCommon Methods borderLines :: NumLines -> [Text] Source #
Lines NumLines Source # |
Instance details Defined in Hledger.Write.Spreadsheet Methods noLine :: NumLines Source #

noBorder :: Lines border => Border border Source #

defaultCell :: Lines border => text -> Cell border text Source #

headerCell :: Lines borders => Text -> Cell borders Text Source #

emptyCell :: (Lines border, Monoid text) => Cell border text Source #

transposeCell :: Cell border text -> Cell border text Source #

transpose :: [[Cell border text]] -> [[Cell border text]] Source #

horizontalSpan :: (Lines border, Monoid text) => [a] -> Cell border text -> [Cell border text] Source #

addHeaderBorders :: [Cell () text] -> [Cell NumLines text] Source #

addRowSpanHeader :: Cell border text -> [[Cell border text]] -> [[Cell border text]] Source #

rawTableContent :: [[Cell border text]] -> [[text]] Source #

cellFromMixedAmount :: Lines border => AmountFormat -> (Class, MixedAmount) -> Cell border WideBuilder Source #

cellsFromMixedAmount :: Lines border => AmountFormat -> (Class, MixedAmount) -> [Cell border WideBuilder] Source #

cellFromAmount :: Lines border => AmountFormat -> (Class, (wb, Amount)) -> Cell border wb Source #

integerCell :: Lines border => Integer -> Cell border Text Source #