Hledger.Write.Spreadsheet

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

Safe Haskell | None
Language | Haskell2010

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 #

Constructors

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

#### Instances

Instances details

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

data Style #

Constructors

Body Emphasis |
Head |

#### Instances

Instances details

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

data Emphasis #

Constructors

Item |
Total |

#### Instances

Instances details

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

data Cell border text #

Constructors

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

#### Instances

Instances details

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

newtype Class #

Constructors

Class Text |

textFromClass :: Class -> Text #

data Span #

- `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 # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Span -> Span -> Bool # (/=) :: Span -> Span -> Bool #

data Border lines #

Constructors

Border |
Fields borderLeft :: lines borderRight :: lines borderTop :: lines borderBottom :: lines

#### Instances

Instances details

Applicative Border # |
Instance details Defined in Hledger.Write.Spreadsheet Methods pure :: a -> Border a # (<*>) :: Border (a -> b) -> Border a -> Border b # liftA2 :: (a -> b -> c) -> Border a -> Border b -> Border c # (*>) :: Border a -> Border b -> Border b # (<*) :: Border a -> Border b -> Border a #
Functor Border # |
Instance details Defined in Hledger.Write.Spreadsheet Methods fmap :: (a -> b) -> Border a -> Border b # (<$) :: a -> Border b -> Border a #
Foldable Border # |
Instance details Defined in Hledger.Write.Spreadsheet Methods fold :: Monoid m => Border m -> m # foldMap :: Monoid m => (a -> m) -> Border a -> m # foldMap' :: Monoid m => (a -> m) -> Border a -> m # foldr :: (a -> b -> b) -> b -> Border a -> b # foldr' :: (a -> b -> b) -> b -> Border a -> b # foldl :: (b -> a -> b) -> b -> Border a -> b # foldl' :: (b -> a -> b) -> b -> Border a -> b # foldr1 :: (a -> a -> a) -> Border a -> a # foldl1 :: (a -> a -> a) -> Border a -> a # toList :: Border a -> [a] # null :: Border a -> Bool # length :: Border a -> Int # elem :: Eq a => a -> Border a -> Bool # maximum :: Ord a => Border a -> a # minimum :: Ord a => Border a -> a # sum :: Num a => Border a -> a # product :: Num a => Border a -> a #
Show lines => Show (Border lines) # |
Instance details Defined in Hledger.Write.Spreadsheet Methods showsPrec :: Int -> Border lines -> ShowS # show :: Border lines -> String # showList :: [Border lines] -> ShowS #
Eq lines => Eq (Border lines) # |
Instance details Defined in Hledger.Write.Spreadsheet Methods (==) :: Border lines -> Border lines -> Bool # (/=) :: Border lines -> Border lines -> Bool #
Ord lines => Ord (Border lines) # |
Instance details Defined in Hledger.Write.Spreadsheet Methods compare :: Border lines -> Border lines -> Ordering # (<) :: Border lines -> Border lines -> Bool # (<=) :: Border lines -> Border lines -> Bool # (>) :: Border lines -> Border lines -> Bool # (>=) :: Border lines -> Border lines -> Bool # max :: Border lines -> Border lines -> Border lines # min :: Border lines -> Border lines -> Border lines #

class Lines border where #

Methods

noLine :: border #

#### Instances

Instances details

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

data NumLines #

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

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 #