xlsx-0.7.2: Simple and incomplete Excel file parser/writer

Safe HaskellNone
LanguageHaskell2010

Codec.Xlsx.Types

Contents

Synopsis

The main types

data Xlsx #

Structured representation of Xlsx file (currently a subset of its contents)

Constructors

Xlsx 

Fields

Instances

Eq Xlsx # 

Methods

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

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

Show Xlsx # 

Methods

showsPrec :: Int -> Xlsx -> ShowS #

show :: Xlsx -> String #

showList :: [Xlsx] -> ShowS #

Generic Xlsx # 

Associated Types

type Rep Xlsx :: * -> * #

Methods

from :: Xlsx -> Rep Xlsx x #

to :: Rep Xlsx x -> Xlsx #

Default Xlsx # 

Methods

def :: Xlsx #

NFData Xlsx # 

Methods

rnf :: Xlsx -> () #

type Rep Xlsx # 

newtype Styles #

Constructors

Styles 

Fields

Instances

Eq Styles # 

Methods

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

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

Show Styles # 
Generic Styles # 

Associated Types

type Rep Styles :: * -> * #

Methods

from :: Styles -> Rep Styles x #

to :: Rep Styles x -> Styles #

NFData Styles # 

Methods

rnf :: Styles -> () #

type Rep Styles # 
type Rep Styles = D1 * (MetaData "Styles" "Codec.Xlsx.Types" "xlsx-0.7.2-lPjfwcf8ew7uO9JhyAhCa" True) (C1 * (MetaCons "Styles" PrefixI True) (S1 * (MetaSel (Just Symbol "unStyles") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * ByteString)))

newtype DefinedNames #

Defined names

Each defined name consists of a name, an optional local sheet ID, and a value.

This element defines the collection of defined names for this workbook. Defined names are descriptive names to represent cells, ranges of cells, formulas, or constant values. Defined names can be used to represent a range on any worksheet.

Excel also defines a number of reserved names with a special interpretation:

  • _xlnm.Print_Area specifies the workbook's print area. Example value: SheetName!$A:$A,SheetName!$1:$4
  • _xlnm.Print_Titles specifies the row(s) or column(s) to repeat at the top of each printed page.
  • _xlnm.Sheet_Title:refers to a sheet title.

and others. See Section 18.2.6, "definedNames (Defined Names)" (p. 1728) of the spec (second edition).

NOTE: Right now this is only a minimal implementation of defined names.

Constructors

DefinedNames [(Text, Maybe Text, Text)] 

Instances

data ColumnsProperties #

Column range (from cwMin to cwMax) properties

Constructors

ColumnsProperties 

Fields

  • cpMin :: Int

    First column affected by this ColumnWidth record.

  • cpMax :: Int

    Last column affected by this ColumnWidth record.

  • cpWidth :: Maybe Double

    Column width measured as the number of characters of the maximum digit width of the numbers 0, 1, 2, ..., 9 as rendered in the normal style's font.

    See longer description in Section 18.3.1.13 "col (Column Width & Formatting)" (p. 1605)

  • cpStyle :: Maybe Int

    Default style for the affected column(s). Affects cells not yet allocated in the column(s). In other words, this style applies to new columns.

  • cpHidden :: Bool

    Flag indicating if the affected column(s) are hidden on this worksheet.

  • cpCollapsed :: Bool

    Flag indicating if the outlining of the affected column(s) is in the collapsed state.

  • cpBestFit :: Bool

    Flag indicating if the specified column(s) is set to 'best fit'.

Instances

Eq ColumnsProperties # 
Show ColumnsProperties # 
Generic ColumnsProperties # 
NFData ColumnsProperties # 

Methods

rnf :: ColumnsProperties -> () #

FromXenoNode ColumnsProperties # 
FromCursor ColumnsProperties # 
ToElement ColumnsProperties # 
type Rep ColumnsProperties # 

data PageSetup #

Constructors

PageSetup 

Fields

Instances

Eq PageSetup # 
Ord PageSetup # 
Show PageSetup # 
Generic PageSetup # 

Associated Types

type Rep PageSetup :: * -> * #

Default PageSetup # 

Methods

def :: PageSetup #

NFData PageSetup # 

Methods

rnf :: PageSetup -> () #

FromXenoNode PageSetup # 
FromCursor PageSetup #

See CT_PageSetup, p. 3922

Methods

fromCursor :: Cursor -> [PageSetup] #

ToElement PageSetup #

See CT_PageSetup, p. 3922

Methods

toElement :: Name -> PageSetup -> Element #

type Rep PageSetup # 
type Rep PageSetup = D1 * (MetaData "PageSetup" "Codec.Xlsx.Types.PageSetup" "xlsx-0.7.2-lPjfwcf8ew7uO9JhyAhCa" False) (C1 * (MetaCons "PageSetup" PrefixI True) ((:*:) * ((:*:) * ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupBlackAndWhite") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Bool))) (S1 * (MetaSel (Just Symbol "_pageSetupCellComments") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe CellComments)))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupCopies") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int))) (S1 * (MetaSel (Just Symbol "_pageSetupDraft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Bool))))) ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupErrors") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe PrintErrors))) (S1 * (MetaSel (Just Symbol "_pageSetupFirstPageNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int)))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupFitToHeight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupFitToWidth") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int))) (S1 * (MetaSel (Just Symbol "_pageSetupHorizontalDpi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int))))))) ((:*:) * ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Text))) (S1 * (MetaSel (Just Symbol "_pageSetupOrientation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Orientation)))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupPageOrder") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe PageOrder))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupPaperHeight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Text))) (S1 * (MetaSel (Just Symbol "_pageSetupPaperSize") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe PaperSize)))))) ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupPaperWidth") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Text))) (S1 * (MetaSel (Just Symbol "_pageSetupScale") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int)))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupUseFirstPageNumber") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Bool))) ((:*:) * (S1 * (MetaSel (Just Symbol "_pageSetupUsePrinterDefaults") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Bool))) (S1 * (MetaSel (Just Symbol "_pageSetupVerticalDpi") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int)))))))))

data Worksheet #

Xlsx worksheet

Instances

Eq Worksheet # 
Show Worksheet # 
Generic Worksheet # 

Associated Types

type Rep Worksheet :: * -> * #

Default Worksheet # 

Methods

def :: Worksheet #

NFData Worksheet # 

Methods

rnf :: Worksheet -> () #

type Rep Worksheet # 
type Rep Worksheet = D1 * (MetaData "Worksheet" "Codec.Xlsx.Types" "xlsx-0.7.2-lPjfwcf8ew7uO9JhyAhCa" False) (C1 * (MetaCons "Worksheet" PrefixI True) ((:*:) * ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_wsColumnsProperties") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [ColumnsProperties])) ((:*:) * (S1 * (MetaSel (Just Symbol "_wsRowPropertiesMap") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Map Int RowProperties))) (S1 * (MetaSel (Just Symbol "_wsCells") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * CellMap)))) ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_wsDrawing") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Drawing))) (S1 * (MetaSel (Just Symbol "_wsMerges") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [Range]))) ((:*:) * (S1 * (MetaSel (Just Symbol "_wsSheetViews") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe [SheetView]))) (S1 * (MetaSel (Just Symbol "_wsPageSetup") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe PageSetup)))))) ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_wsConditionalFormattings") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Map SqRef ConditionalFormatting))) ((:*:) * (S1 * (MetaSel (Just Symbol "_wsDataValidations") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Map SqRef DataValidation))) (S1 * (MetaSel (Just Symbol "_wsPivotTables") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [PivotTable])))) ((:*:) * ((:*:) * (S1 * (MetaSel (Just Symbol "_wsAutoFilter") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe AutoFilter))) (S1 * (MetaSel (Just Symbol "_wsTables") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [Table]))) ((:*:) * (S1 * (MetaSel (Just Symbol "_wsProtection") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe SheetProtection))) (S1 * (MetaSel (Just Symbol "_wsSharedFormulas") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Map SharedFormulaIndex SharedFormulaOptions))))))))

type CellMap = Map (Int, Int) Cell #

Map containing cell values which are indexed by row and column if you need to use more traditional (x,y) indexing please you could use corresponding accessors from 'Lens'

data CellValue #

Cell values include text, numbers and booleans, standard includes date format also but actually dates are represented by numbers with a date format assigned to a cell containing it

Instances

Eq CellValue # 
Ord CellValue # 
Show CellValue # 
Generic CellValue # 

Associated Types

type Rep CellValue :: * -> * #

NFData CellValue # 

Methods

rnf :: CellValue -> () #

type Rep CellValue # 

data CellFormula #

Formula for the cell.

TODO: array, dataTable formula types support

See 18.3.1.40 "f (Formula)" (p. 1636)

Constructors

CellFormula 

Fields

Instances

newtype SharedFormulaIndex #

index of shared formula in worksheet's wsSharedFormulas property

Constructors

SharedFormulaIndex Int 

Instances

Eq SharedFormulaIndex # 
Ord SharedFormulaIndex # 
Show SharedFormulaIndex # 
Generic SharedFormulaIndex # 
NFData SharedFormulaIndex # 

Methods

rnf :: SharedFormulaIndex -> () #

FromAttrBs SharedFormulaIndex # 
FromAttrVal SharedFormulaIndex # 
ToAttrVal SharedFormulaIndex # 
type Rep SharedFormulaIndex # 
type Rep SharedFormulaIndex = D1 * (MetaData "SharedFormulaIndex" "Codec.Xlsx.Types.Cell" "xlsx-0.7.2-lPjfwcf8ew7uO9JhyAhCa" True) (C1 * (MetaCons "SharedFormulaIndex" PrefixI False) (S1 * (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Int)))

data Cell #

Currently cell details include cell values, style ids and cell formulas (inline strings from <is> subelements are ignored)

Instances

Eq Cell # 

Methods

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

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

Show Cell # 

Methods

showsPrec :: Int -> Cell -> ShowS #

show :: Cell -> String #

showList :: [Cell] -> ShowS #

Generic Cell # 

Associated Types

type Rep Cell :: * -> * #

Methods

from :: Cell -> Rep Cell x #

to :: Rep Cell x -> Cell #

Default Cell # 

Methods

def :: Cell #

NFData Cell # 

Methods

rnf :: Cell -> () #

type Rep Cell # 

data RowHeight #

Height of a row in points (1/72in)

Constructors

CustomHeight !Double

Row height is set by the user

AutomaticHeight !Double

Row height is set automatically by the program

data RowProperties #

Properties of a row. See §18.3.1.73 "row (Row)" for more details

Constructors

RowProps 

Fields

Instances

Eq RowProperties # 
Ord RowProperties # 
Read RowProperties # 
Show RowProperties # 
Generic RowProperties # 

Associated Types

type Rep RowProperties :: * -> * #

Default RowProperties # 

Methods

def :: RowProperties #

NFData RowProperties # 

Methods

rnf :: RowProperties -> () #

type Rep RowProperties # 
type Rep RowProperties = D1 * (MetaData "RowProperties" "Codec.Xlsx.Types" "xlsx-0.7.2-lPjfwcf8ew7uO9JhyAhCa" False) (C1 * (MetaCons "RowProps" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "rowHeight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe RowHeight))) ((:*:) * (S1 * (MetaSel (Just Symbol "rowStyle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int))) (S1 * (MetaSel (Just Symbol "rowHidden") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Bool)))))

Lenses

Workbook

Worksheet

Cells

Style helpers

renderStyleSheet :: StyleSheet -> Styles #

Render StyleSheet

This is used to render a structured StyleSheet into a raw XML Styles document. Actually replacing Styles with StyleSheet would mean we would need to write a parser for StyleSheet as well (and would moreover require that we support the full style sheet specification, which is still quite a bit of work).

parseStyleSheet :: Styles -> Either SomeException StyleSheet #

Parse StyleSheet

This is used to parse raw Styles into structured StyleSheet currently not all of the style sheet specification is supported so parser (and the data model) is to be completed

Misc

def :: Default a => a #

The default value for this type.

toRows :: CellMap -> [(Int, [(Int, Cell)])] #

converts cells mapped by (row, column) into rows which contain row index and cells as pairs of column indices and cell values

fromRows :: [(Int, [(Int, Cell)])] -> CellMap #

reverse to toRows