Safe Haskell | None |
---|---|
Language | Haskell2010 |
Codec.Xlsx.Types.StyleSheet
Contents
Description
Support for writing (but not reading) style sheets
- data StyleSheet = StyleSheet {
- _styleSheetBorders :: [Border]
- _styleSheetCellXfs :: [CellXf]
- _styleSheetFills :: [Fill]
- _styleSheetFonts :: [Font]
- _styleSheetDxfs :: [Dxf]
- _styleSheetNumFmts :: Map Int FormatCode
- data CellXf = CellXf {
- _cellXfApplyAlignment :: Maybe Bool
- _cellXfApplyBorder :: Maybe Bool
- _cellXfApplyFill :: Maybe Bool
- _cellXfApplyFont :: Maybe Bool
- _cellXfApplyNumberFormat :: Maybe Bool
- _cellXfApplyProtection :: Maybe Bool
- _cellXfBorderId :: Maybe Int
- _cellXfFillId :: Maybe Int
- _cellXfFontId :: Maybe Int
- _cellXfNumFmtId :: Maybe Int
- _cellXfPivotButton :: Maybe Bool
- _cellXfQuotePrefix :: Maybe Bool
- _cellXfId :: Maybe Int
- _cellXfAlignment :: Maybe Alignment
- _cellXfProtection :: Maybe Protection
- minimalStyleSheet :: StyleSheet
- data Alignment = Alignment {
- _alignmentHorizontal :: Maybe CellHorizontalAlignment
- _alignmentIndent :: Maybe Int
- _alignmentJustifyLastLine :: Maybe Bool
- _alignmentReadingOrder :: Maybe ReadingOrder
- _alignmentRelativeIndent :: Maybe Int
- _alignmentShrinkToFit :: Maybe Bool
- _alignmentTextRotation :: Maybe Int
- _alignmentVertical :: Maybe CellVerticalAlignment
- _alignmentWrapText :: Maybe Bool
- data Border = Border {
- _borderDiagonalDown :: Maybe Bool
- _borderDiagonalUp :: Maybe Bool
- _borderOutline :: Maybe Bool
- _borderBottom :: Maybe BorderStyle
- _borderDiagonal :: Maybe BorderStyle
- _borderEnd :: Maybe BorderStyle
- _borderHorizontal :: Maybe BorderStyle
- _borderLeft :: Maybe BorderStyle
- _borderRight :: Maybe BorderStyle
- _borderStart :: Maybe BorderStyle
- _borderTop :: Maybe BorderStyle
- _borderVertical :: Maybe BorderStyle
- data BorderStyle = BorderStyle {}
- data Color = Color {}
- data Dxf = Dxf {}
- data Fill = Fill {}
- data FillPattern = FillPattern {}
- data Font = Font {
- _fontBold :: Maybe Bool
- _fontCharset :: Maybe Int
- _fontColor :: Maybe Color
- _fontCondense :: Maybe Bool
- _fontExtend :: Maybe Bool
- _fontFamily :: Maybe FontFamily
- _fontItalic :: Maybe Bool
- _fontName :: Maybe Text
- _fontOutline :: Maybe Bool
- _fontScheme :: Maybe FontScheme
- _fontShadow :: Maybe Bool
- _fontStrikeThrough :: Maybe Bool
- _fontSize :: Maybe Double
- _fontUnderline :: Maybe FontUnderline
- _fontVertAlign :: Maybe FontVerticalAlignment
- data NumberFormat
- data NumFmt = NumFmt {}
- data ImpliedNumberFormat
- = NfGeneral
- | NfZero
- | Nf2Decimal
- | NfMax3Decimal
- | NfThousandSeparator2Decimal
- | NfPercent
- | NfPercent2Decimal
- | NfExponent2Decimal
- | NfSingleSpacedFraction
- | NfDoubleSpacedFraction
- | NfMmDdYy
- | NfDMmmYy
- | NfDMmm
- | NfMmmYy
- | NfHMm12Hr
- | NfHMmSs12Hr
- | NfHMm
- | NfHMmSs
- | NfMdyHMm
- | NfThousandsNegativeParens
- | NfThousandsNegativeRed
- | NfThousands2DecimalNegativeParens
- | NfThousands2DecimalNegativeRed
- | NfMmSs
- | NfOptHMmSs
- | NfMmSs1Decimal
- | NfExponent1Decimal
- | NfTextPlaceHolder
- | NfOtherImplied Int
- type FormatCode = Text
- data Protection = Protection {}
- data CellHorizontalAlignment
- data CellVerticalAlignment
- data FontFamily
- data FontScheme
- data FontUnderline
- data FontVerticalAlignment
- data LineStyle
- data PatternType
- = PatternTypeDarkDown
- | PatternTypeDarkGray
- | PatternTypeDarkGrid
- | PatternTypeDarkHorizontal
- | PatternTypeDarkTrellis
- | PatternTypeDarkUp
- | PatternTypeDarkVertical
- | PatternTypeGray0625
- | PatternTypeGray125
- | PatternTypeLightDown
- | PatternTypeLightGray
- | PatternTypeLightGrid
- | PatternTypeLightHorizontal
- | PatternTypeLightTrellis
- | PatternTypeLightUp
- | PatternTypeLightVertical
- | PatternTypeMediumGray
- | PatternTypeNone
- | PatternTypeSolid
- data ReadingOrder
- styleSheetBorders :: Lens' StyleSheet [Border]
- styleSheetFonts :: Lens' StyleSheet [Font]
- styleSheetFills :: Lens' StyleSheet [Fill]
- styleSheetCellXfs :: Lens' StyleSheet [CellXf]
- styleSheetDxfs :: Lens' StyleSheet [Dxf]
- styleSheetNumFmts :: Lens' StyleSheet (Map Int FormatCode)
- cellXfApplyAlignment :: Lens' CellXf (Maybe Bool)
- cellXfApplyBorder :: Lens' CellXf (Maybe Bool)
- cellXfApplyFill :: Lens' CellXf (Maybe Bool)
- cellXfApplyFont :: Lens' CellXf (Maybe Bool)
- cellXfApplyNumberFormat :: Lens' CellXf (Maybe Bool)
- cellXfApplyProtection :: Lens' CellXf (Maybe Bool)
- cellXfBorderId :: Lens' CellXf (Maybe Int)
- cellXfFillId :: Lens' CellXf (Maybe Int)
- cellXfFontId :: Lens' CellXf (Maybe Int)
- cellXfNumFmtId :: Lens' CellXf (Maybe Int)
- cellXfPivotButton :: Lens' CellXf (Maybe Bool)
- cellXfQuotePrefix :: Lens' CellXf (Maybe Bool)
- cellXfId :: Lens' CellXf (Maybe Int)
- cellXfAlignment :: Lens' CellXf (Maybe Alignment)
- cellXfProtection :: Lens' CellXf (Maybe Protection)
- dxfAlignment :: Lens' Dxf (Maybe Alignment)
- dxfBorder :: Lens' Dxf (Maybe Border)
- dxfFill :: Lens' Dxf (Maybe Fill)
- dxfFont :: Lens' Dxf (Maybe Font)
- dxfNumFmt :: Lens' Dxf (Maybe NumFmt)
- dxfProtection :: Lens' Dxf (Maybe Protection)
- alignmentHorizontal :: Lens' Alignment (Maybe CellHorizontalAlignment)
- alignmentIndent :: Lens' Alignment (Maybe Int)
- alignmentJustifyLastLine :: Lens' Alignment (Maybe Bool)
- alignmentReadingOrder :: Lens' Alignment (Maybe ReadingOrder)
- alignmentRelativeIndent :: Lens' Alignment (Maybe Int)
- alignmentShrinkToFit :: Lens' Alignment (Maybe Bool)
- alignmentTextRotation :: Lens' Alignment (Maybe Int)
- alignmentVertical :: Lens' Alignment (Maybe CellVerticalAlignment)
- alignmentWrapText :: Lens' Alignment (Maybe Bool)
- borderDiagonalDown :: Lens' Border (Maybe Bool)
- borderDiagonalUp :: Lens' Border (Maybe Bool)
- borderOutline :: Lens' Border (Maybe Bool)
- borderBottom :: Lens' Border (Maybe BorderStyle)
- borderDiagonal :: Lens' Border (Maybe BorderStyle)
- borderEnd :: Lens' Border (Maybe BorderStyle)
- borderHorizontal :: Lens' Border (Maybe BorderStyle)
- borderStart :: Lens' Border (Maybe BorderStyle)
- borderTop :: Lens' Border (Maybe BorderStyle)
- borderVertical :: Lens' Border (Maybe BorderStyle)
- borderLeft :: Lens' Border (Maybe BorderStyle)
- borderRight :: Lens' Border (Maybe BorderStyle)
- borderStyleColor :: Lens' BorderStyle (Maybe Color)
- borderStyleLine :: Lens' BorderStyle (Maybe LineStyle)
- colorAutomatic :: Lens' Color (Maybe Bool)
- colorARGB :: Lens' Color (Maybe Text)
- colorTheme :: Lens' Color (Maybe Int)
- colorTint :: Lens' Color (Maybe Double)
- fillPattern :: Iso' Fill (Maybe FillPattern)
- fillPatternBgColor :: Lens' FillPattern (Maybe Color)
- fillPatternFgColor :: Lens' FillPattern (Maybe Color)
- fillPatternType :: Lens' FillPattern (Maybe PatternType)
- fontBold :: Lens' Font (Maybe Bool)
- fontCharset :: Lens' Font (Maybe Int)
- fontColor :: Lens' Font (Maybe Color)
- fontCondense :: Lens' Font (Maybe Bool)
- fontExtend :: Lens' Font (Maybe Bool)
- fontFamily :: Lens' Font (Maybe FontFamily)
- fontItalic :: Lens' Font (Maybe Bool)
- fontName :: Lens' Font (Maybe Text)
- fontOutline :: Lens' Font (Maybe Bool)
- fontScheme :: Lens' Font (Maybe FontScheme)
- fontShadow :: Lens' Font (Maybe Bool)
- fontStrikeThrough :: Lens' Font (Maybe Bool)
- fontSize :: Lens' Font (Maybe Double)
- fontUnderline :: Lens' Font (Maybe FontUnderline)
- fontVertAlign :: Lens' Font (Maybe FontVerticalAlignment)
- protectionHidden :: Lens' Protection (Maybe Bool)
- protectionLocked :: Lens' Protection (Maybe Bool)
- fmtDecimals :: Int -> NumberFormat
- fmtDecimalsZeroes :: Int -> NumberFormat
- stdNumberFormatId :: ImpliedNumberFormat -> Int
- idToStdNumberFormat :: Int -> Maybe ImpliedNumberFormat
- firstUserNumFmtId :: Int
The main two types
data StyleSheet #
StyleSheet for an XML document
Relevant parts of the EMCA standard (4th edition, part 1, http://www.ecma-international.org/publications/standards/Ecma-376.htm), page numbers refer to the page in the PDF rather than the page number as printed on the page):
- Chapter 12, SpreadsheetML (p. 74) In particular Section 12.3.20, "Styles Part" (p. 104)
- Chapter 18, "SpreadsheetML Reference Material" (p. 1528) In particular Section 18.8, Styles (p. 1754) and Section 18.8.39 "styleSheet" (Style Sheet)" (p. 1796); it is the latter section that specifies the top-level style sheet format.
TODO: the following child elements:
- cellStyles
- cellStyleXfs
- colors
- extLst
- tableStyles
NOTE: You will probably want to base your style sheet on minimalStyleSheet
.
See also:
renderStyleSheet
to translate aStyleSheet
toStyles
formatted
for a higher level interface.parseStyleSheet
to translate a rawStyleSheet
intoStyles
Constructors
StyleSheet | |
Fields
|
Instances
Eq StyleSheet # | |
Ord StyleSheet # | |
Show StyleSheet # | |
Generic StyleSheet # | |
Default StyleSheet # | |
NFData StyleSheet # | |
FromCursor StyleSheet # | See |
ToElement StyleSheet # | See |
ToDocument StyleSheet # | |
type Rep StyleSheet # | |
Cell formatting
TODO: The extLst
field is currently unsupported.
Section 18.8.45 "xf (Format)" (p. 1800)
Constructors
CellXf | |
Fields
|
minimalStyleSheet :: StyleSheet #
Minimal style sheet
Excel expects some minimal definitions in the stylesheet; you probably want to define your own stylesheets based on this one.
This more-or-less follows the recommendations at http://stackoverflow.com/questions/26050708/minimal-style-sheet-for-excel-open-xml-with-dates, but with some additions based on experimental evidence.
Supporting record types
Alignment
See 18.8.1 "alignment (Alignment)" (p. 1754)
Constructors
Alignment | |
Fields
|
Expresses a single set of cell border formats (left, right, top, bottom,
diagonal). Color is optional. When missing, automatic
is implied.
See 18.8.4 "border (Border)" (p. 1759)
Constructors
Border | |
Fields
|
data BorderStyle #
Border style
See CT_BorderPr
(p. 3934)
Constructors
BorderStyle | |
Fields |
Instances
Eq BorderStyle # | |
Ord BorderStyle # | |
Show BorderStyle # | |
Generic BorderStyle # | |
Default BorderStyle # | |
NFData BorderStyle # | |
FromCursor BorderStyle # | |
ToElement BorderStyle # | See |
type Rep BorderStyle # | |
One of the colors associated with the data bar or color scale.
The indexed
attribute (used for backwards compatibility only) is not
modelled here.
See 18.3.1.15 "color (Data Bar Color)" (p. 1608)
Constructors
Color | |
Fields
|
A single dxf record, expressing incremental formatting to be applied.
Section 18.8.14, "dxf (Formatting)" (p. 1765)
Constructors
Dxf | |
Fields
|
This element specifies fill formatting.
TODO: Gradient fills (18.8.4) are currently unsupported. If we add them,
then the spec says (CT_Fill
, p. 3935), _either_ a gradient _or_ a solid
fill pattern should be specified.
Section 18.8.20, "fill (Fill)" (p. 1768)
Constructors
Fill | |
Fields |
data FillPattern #
This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern), fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element.
Section 18.8.32 "patternFill (Pattern)" (p. 1793)
Constructors
FillPattern | |
Fields |
Instances
Eq FillPattern # | |
Ord FillPattern # | |
Show FillPattern # | |
Generic FillPattern # | |
Default FillPattern # | |
NFData FillPattern # | |
FromCursor FillPattern # | See |
ToElement FillPattern # | See |
type Rep FillPattern # | |
This element defines the properties for one of the fonts used in this workbook.
Section 18.2.22 "font (Font)" (p. 1769)
Constructors
Font | |
Fields
|
data NumberFormat #
This type gives a high-level version of representation of number format
used in Format
.
Constructors
StdNumberFormat ImpliedNumberFormat | |
UserNumberFormat FormatCode |
Instances
This element specifies number format properties which indicate how to format and render the numeric value of a cell.
Section 18.8.30 "numFmt (Number Format)" (p. 1777)
Constructors
NumFmt | |
Fields
|
data ImpliedNumberFormat #
Implied number formats
Note: This only implements the predefined values for 18.2.30 "All Languages",
other built-in format ids (with id < firstUserNumFmtId
) are stored in NfOtherBuiltin
Constructors
NfGeneral | 0 General |
NfZero | 1 0 |
Nf2Decimal | 2 0.00 |
NfMax3Decimal | 3 #,##0 |
NfThousandSeparator2Decimal | 4 #,##0.00 |
NfPercent | 9 0% |
NfPercent2Decimal | 10 0.00% |
NfExponent2Decimal | 11 0.00E+00 |
NfSingleSpacedFraction | 12 # ?/? |
NfDoubleSpacedFraction | 13 # ??/?? |
NfMmDdYy | 14 mm-dd-yy |
NfDMmmYy | 15 d-mmm-yy |
NfDMmm | 16 d-mmm |
NfMmmYy | 17 mmm-yy |
NfHMm12Hr | 18 h:mm AM/PM |
NfHMmSs12Hr | 19 h:mm:ss AM/PM |
NfHMm | 20 h:mm |
NfHMmSs | 21 h:mm:ss |
NfMdyHMm | 22 m/d/yy h:mm |
NfThousandsNegativeParens | 37 #,##0 ;(#,##0) |
NfThousandsNegativeRed | 38 #,##0 ;[Red](#,##0) |
NfThousands2DecimalNegativeParens | 39 #,##0.00;(#,##0.00) |
NfThousands2DecimalNegativeRed | 40 #,##0.00;[Red](#,##0.00) |
NfMmSs | 45 mm:ss |
NfOptHMmSs | 46 [h]:mm:ss |
NfMmSs1Decimal | 47 mmss.0 |
NfExponent1Decimal | 48 ##0.0E+0 |
NfTextPlaceHolder | 49 @ |
NfOtherImplied Int | other (non local-neutral?) built-in format (id < 164) |
type FormatCode = Text #
A number format code.
Section 18.8.30, "numFmt (Number Format)" (p. 1777)
data Protection #
Protection properties
Contains protection properties associated with the cell. Each cell has protection properties that can be set. The cell protection properties do not take effect unless the sheet has been protected.
Section 18.8.33, "protection (Protection Properties)", p. 1793
Constructors
Protection | |
Fields |
Instances
Eq Protection # | |
Ord Protection # | |
Show Protection # | |
Generic Protection # | |
Default Protection # | |
NFData Protection # | |
FromCursor Protection # | See |
ToElement Protection # | See |
type Rep Protection # | |
Supporting enumerations
data CellHorizontalAlignment #
Horizontal alignment in cells
See 18.18.40 "ST_HorizontalAlignment (Horizontal Alignment Type)" (p. 2459)
data CellVerticalAlignment #
Vertical alignment in cells
See 18.18.88 "ST_VerticalAlignment (Vertical Alignment Types)" (p. 2512)
data FontFamily #
Font family
See 18.8.18 "family (Font Family)" (p. 1766) and 17.18.30 "ST_FontFamily (Font Family Value)" (p. 1388)
Constructors
FontFamilyNotApplicable | Family is not applicable |
FontFamilyRoman | Proportional font with serifs |
FontFamilySwiss | Proportional font without serifs |
FontFamilyModern | Monospace font with or without serifs |
FontFamilyScript | Script font designed to mimic the appearance of handwriting |
FontFamilyDecorative | Novelty font |
Instances
Eq FontFamily # | |
Ord FontFamily # | |
Show FontFamily # | |
Generic FontFamily # | |
NFData FontFamily # | |
FromAttrBs FontFamily # | |
FromAttrVal FontFamily # | See 18.18.94 "ST_FontFamily (Font Family)" (p. 2517) |
ToAttrVal FontFamily # | |
type Rep FontFamily # | |
data FontScheme #
Font scheme
See 18.18.33 "ST_FontScheme (Font scheme Styles)" (p. 2456)
Constructors
FontSchemeMajor | This font is the major font for this theme. |
FontSchemeMinor | This font is the minor font for this theme. |
FontSchemeNone | This font is not a theme font. |
Instances
data FontUnderline #
Font underline property
See 18.4.13 "u (Underline)", p 1728
data FontVerticalAlignment #
Vertical alignment
See 22.9.2.17 "ST_VerticalAlignRun (Vertical Positioning Location)" (p. 3794)
data PatternType #
Indicates the style of fill pattern being used for a cell format.
Section 18.18.55 "ST_PatternType (Pattern Type)" (p. 2472)
Constructors
Instances
Lenses
StyleSheet
styleSheetFonts :: Lens' StyleSheet [Font] #
styleSheetFills :: Lens' StyleSheet [Fill] #
styleSheetDxfs :: Lens' StyleSheet [Dxf] #
CellXf
Dxf
dxfProtection :: Lens' Dxf (Maybe Protection) #
Alignment
Border
borderBottom :: Lens' Border (Maybe BorderStyle) #
borderStart :: Lens' Border (Maybe BorderStyle) #
borderLeft :: Lens' Border (Maybe BorderStyle) #
borderRight :: Lens' Border (Maybe BorderStyle) #
BorderStyle
Color
Fill
fillPattern :: Iso' Fill (Maybe FillPattern) #
FillPattern
Font
fontFamily :: Lens' Font (Maybe FontFamily) #
fontScheme :: Lens' Font (Maybe FontScheme) #
Protection
Helpers
Number formats
fmtDecimals :: Int -> NumberFormat #
Basic number format with predefined number of decimals as format code of number format in xlsx should be less than 255 characters number of decimals shouldn't be more than 253
fmtDecimalsZeroes :: Int -> NumberFormat #
Basic number format with predefined number of decimals.
Works like fmtDecimals
with the only difference that extra zeroes are
displayed when number of digits after the point is less than the number
of digits specified in the format