xlsx-1.1.0.1: Simple and incomplete Excel file parser/writer
Safe HaskellSafe-Inferred
LanguageHaskell2010

Codec.Xlsx.Formatted

Description

Higher level interface for creating styled worksheets

Synopsis

Documentation

data FormattedCell Source #

Cell with formatting. _cellStyle property of _formattedCell is ignored

See formatted for more details.

Instances

Instances details
Generic FormattedCell Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Associated Types

type Rep FormattedCell :: Type -> Type #

Show FormattedCell Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Default FormattedCell Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Methods

def :: FormattedCell #

Eq FormattedCell Source # 
Instance details

Defined in Codec.Xlsx.Formatted

type Rep FormattedCell Source # 
Instance details

Defined in Codec.Xlsx.Formatted

type Rep FormattedCell = D1 ('MetaData "FormattedCell" "Codec.Xlsx.Formatted" "xlsx-1.1.0.1-FKUF1Jx3xuq9irRu3xJWCs" 'False) (C1 ('MetaCons "FormattedCell" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_formattedCell") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Cell) :*: S1 ('MetaSel ('Just "_formattedFormat") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Format)) :*: (S1 ('MetaSel ('Just "_formattedColSpan") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "_formattedRowSpan") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))))

data Formatted Source #

Result of formatting

See formatted

Constructors

Formatted 

Fields

Instances

Instances details
Generic Formatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Associated Types

type Rep Formatted :: Type -> Type #

Show Formatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Eq Formatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

type Rep Formatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

type Rep Formatted = D1 ('MetaData "Formatted" "Codec.Xlsx.Formatted" "xlsx-1.1.0.1-FKUF1Jx3xuq9irRu3xJWCs" 'False) (C1 ('MetaCons "Formatted" 'PrefixI 'True) (S1 ('MetaSel ('Just "formattedCellMap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CellMap) :*: (S1 ('MetaSel ('Just "formattedStyleSheet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StyleSheet) :*: S1 ('MetaSel ('Just "formattedMerges") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Range]))))

data Format Source #

Formatting options used to format cells

TODOs:

Instances

Instances details
Generic Format Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Associated Types

type Rep Format :: Type -> Type #

Methods

from :: Format -> Rep Format x #

to :: Rep Format x -> Format #

Show Format Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Default Format Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Methods

def :: Format #

Eq Format Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Methods

(==) :: Format -> Format -> Bool #

(/=) :: Format -> Format -> Bool #

type Rep Format Source # 
Instance details

Defined in Codec.Xlsx.Formatted

formatted :: Map (RowIndex, ColumnIndex) FormattedCell -> StyleSheet -> Formatted Source #

Higher level API for creating formatted documents

Creating formatted Excel spreadsheets using the Cell datatype directly, even with the support for the StyleSheet datatype, is fairly painful. This has a number of causes:

  • The Cell datatype wants an Int for the style, which is supposed to point into the _styleSheetCellXfs part of a stylesheet. However, this can be difficult to work with, as it requires manual tracking of cell style IDs, which in turns requires manual tracking of font IDs, border IDs, etc.
  • Row-span and column-span properties are set on the worksheet as a whole (wsMerges) rather than on individual cells.
  • Excel does not correctly deal with borders on cells that span multiple columns or rows. Instead, these rows must be set on all the edge cells in the block. Again, this means that this becomes a global property of the spreadsheet rather than properties of individual cells.

This function deals with all these problems. Given a map of FormattedCells, which refer directly to Fonts, Borders, etc. (rather than font IDs, border IDs, etc.), and an initial stylesheet, it recovers all possible sharing, constructs IDs, and then constructs the final CellMap, as well as the final stylesheet and list of merges.

If you don't already have a StyleSheet you want to use as starting point then minimalStyleSheet is a good choice.

formatWorkbook :: [(Text, Map (RowIndex, ColumnIndex) FormattedCell)] -> StyleSheet -> Xlsx Source #

Build an Xlsx, render provided cells as per the StyleSheet.

toFormattedCells :: CellMap -> [Range] -> StyleSheet -> Map (RowIndex, ColumnIndex) FormattedCell Source #

reverse to formatted which allows to get a map of formatted cells from an existing worksheet and its workbook's style sheet

data CondFormatted Source #

Constructors

CondFormatted 

Fields

Instances

Instances details
Generic CondFormatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Associated Types

type Rep CondFormatted :: Type -> Type #

Show CondFormatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

Eq CondFormatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

type Rep CondFormatted Source # 
Instance details

Defined in Codec.Xlsx.Formatted

type Rep CondFormatted = D1 ('MetaData "CondFormatted" "Codec.Xlsx.Formatted" "xlsx-1.1.0.1-FKUF1Jx3xuq9irRu3xJWCs" 'False) (C1 ('MetaCons "CondFormatted" 'PrefixI 'True) (S1 ('MetaSel ('Just "condformattedStyleSheet") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 StyleSheet) :*: S1 ('MetaSel ('Just "condformattedFormattings") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map SqRef ConditionalFormatting))))

Lenses

Format

FormattedCell

FormattedCondFmt

condfmtDxf :: Lens' FormattedCondFmt Dxf Source #

condfmtPriority :: Lens' FormattedCondFmt Int Source #

condfmtStopIfTrue :: Lens' FormattedCondFmt (Maybe Bool) Source #