Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Support for writing (but not reading) style sheets
Synopsis
- 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 Source #
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: Because of undocumented Excel requirements you will probably want to base
your style sheet on minimalStyleSheet
(a proper style sheet should have some
contents for details see
SO post).
def
for StyleSheet
includes no contents at all and this could be a problem
for Excel.
See also:
renderStyleSheet
to translate aStyleSheet
toStyles
formatted
for a higher level interface.parseStyleSheet
to translate a rawStyleSheet
intoStyles
StyleSheet | |
|
Instances
Cell formatting
TODO: The extLst
field is currently unsupported.
Section 18.8.45 "xf (Format)" (p. 1800)
CellXf | |
|
Instances
minimalStyleSheet :: StyleSheet Source #
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)
Alignment | |
|
Instances
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)
Border | |
|
Instances
data BorderStyle Source #
Border style
See CT_BorderPr
(p. 3934)
Instances
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)
Color | |
|
Instances
A single dxf record, expressing incremental formatting to be applied.
Section 18.8.14, "dxf (Formatting)" (p. 1765)
Dxf | |
|
Instances
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)
Instances
Generic Fill Source # | |
Show Fill Source # | |
Default Fill Source # | |
Defined in Codec.Xlsx.Types.StyleSheet | |
NFData Fill Source # | |
Defined in Codec.Xlsx.Types.StyleSheet | |
Eq Fill Source # | |
Ord Fill Source # | |
FromCursor Fill Source # | See |
Defined in Codec.Xlsx.Types.StyleSheet fromCursor :: Cursor -> [Fill] Source # | |
ToElement Fill Source # | See |
type Rep Fill Source # | |
Defined in Codec.Xlsx.Types.StyleSheet type Rep Fill = D1 ('MetaData "Fill" "Codec.Xlsx.Types.StyleSheet" "xlsx-1.1.0.1-FKUF1Jx3xuq9irRu3xJWCs" 'False) (C1 ('MetaCons "Fill" 'PrefixI 'True) (S1 ('MetaSel ('Just "_fillPattern") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe FillPattern)))) |
data FillPattern Source #
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)
Instances
This element defines the properties for one of the fonts used in this workbook.
Section 18.2.22 "font (Font)" (p. 1769)
Font | |
|
Instances
data NumberFormat Source #
This type gives a high-level version of representation of number format
used in Format
.
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)
NumFmt | |
|
Instances
Generic NumFmt Source # | |
Show NumFmt Source # | |
NFData NumFmt Source # | |
Defined in Codec.Xlsx.Types.StyleSheet | |
Eq NumFmt Source # | |
Ord NumFmt Source # | |
FromCursor NumFmt Source # | See |
Defined in Codec.Xlsx.Types.StyleSheet fromCursor :: Cursor -> [NumFmt] Source # | |
ToElement NumFmt Source # | See |
type Rep NumFmt Source # | |
Defined in Codec.Xlsx.Types.StyleSheet type Rep NumFmt = D1 ('MetaData "NumFmt" "Codec.Xlsx.Types.StyleSheet" "xlsx-1.1.0.1-FKUF1Jx3xuq9irRu3xJWCs" 'False) (C1 ('MetaCons "NumFmt" 'PrefixI 'True) (S1 ('MetaSel ('Just "_numFmtId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "_numFmtCode") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FormatCode))) |
data ImpliedNumberFormat Source #
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
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) |
Instances
type FormatCode = Text Source #
A number format code.
Section 18.8.30, "numFmt (Number Format)" (p. 1777)
data Protection Source #
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
Instances
Supporting enumerations
data CellHorizontalAlignment Source #
Horizontal alignment in cells
See 18.18.40 "ST_HorizontalAlignment (Horizontal Alignment Type)" (p. 2459)
Instances
data CellVerticalAlignment Source #
Vertical alignment in cells
See 18.18.88 "ST_VerticalAlignment (Vertical Alignment Types)" (p. 2512)
CellVerticalAlignmentBottom | |
CellVerticalAlignmentCenter | |
CellVerticalAlignmentDistributed | |
CellVerticalAlignmentJustify | |
CellVerticalAlignmentTop |
Instances
data FontFamily Source #
Font family
See 18.8.18 "family (Font Family)" (p. 1766) and 17.18.30 "ST_FontFamily (Font Family Value)" (p. 1388)
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
data FontScheme Source #
Font scheme
See 18.18.33 "ST_FontScheme (Font scheme Styles)" (p. 2456)
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 Source #
Font underline property
See 18.4.13 "u (Underline)", p 1728
FontUnderlineSingle | |
FontUnderlineDouble | |
FontUnderlineSingleAccounting | |
FontUnderlineDoubleAccounting | |
FontUnderlineNone |
Instances
data FontVerticalAlignment Source #
Vertical alignment
See 22.9.2.17 "ST_VerticalAlignRun (Vertical Positioning Location)" (p. 3794)
Instances
Instances
data PatternType Source #
Indicates the style of fill pattern being used for a cell format.
Section 18.18.55 "ST_PatternType (Pattern Type)" (p. 2472)
Instances
data ReadingOrder Source #
Reading order
See 18.8.1 "alignment (Alignment)" (p. 1754, esp. p. 1755)
Instances
Lenses
StyleSheet
styleSheetDxfs :: Lens' StyleSheet [Dxf] Source #
CellXf
Dxf
dxfProtection :: Lens' Dxf (Maybe Protection) Source #
Alignment
Border
borderLeft :: Lens' Border (Maybe BorderStyle) Source #
BorderStyle
Color
Fill
fillPattern :: Iso' Fill (Maybe FillPattern) Source #
FillPattern
Font
fontFamily :: Lens' Font (Maybe FontFamily) Source #
fontScheme :: Lens' Font (Maybe FontScheme) Source #
Protection
Helpers
Number formats
fmtDecimals :: Int -> NumberFormat Source #
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 Source #
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