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

Safe HaskellNone
LanguageHaskell2010

Codec.Xlsx.Types

Synopsis

Documentation

data Xlsx Source

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

def :: Default a => a

The default value for this type.

newtype Styles Source

Constructors

Styles 

Fields

unStyles :: ByteString
 

renderStyleSheet :: StyleSheet -> Styles Source

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 Source

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

newtype DefinedNames Source

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)] 

data ColumnsWidth Source

Column range (from cwMin to cwMax) width

Constructors

ColumnsWidth 

Fields

cwMin :: Int
 
cwMax :: Int
 
cwWidth :: Double
 
cwStyle :: Int
 

data PageSetup Source

Constructors

PageSetup 

Fields

_pageSetupBlackAndWhite :: Maybe Bool

Print black and white.

_pageSetupCellComments :: Maybe CellComments

This attribute specifies how to print cell comments.

_pageSetupCopies :: Maybe Int

Number of copies to print.

_pageSetupDraft :: Maybe Bool

Print without graphics.

_pageSetupErrors :: Maybe PrintErrors

Specifies how to print cell values for cells with errors.

_pageSetupFirstPageNumber :: Maybe Int

Page number for first printed page. If no value is specified, then automatic is assumed.

_pageSetupFitToHeight :: Maybe Int

Number of vertical pages to fit on.

_pageSetupFitToWidth :: Maybe Int

Number of horizontal pages to fit on.

_pageSetupHorizontalDpi :: Maybe Int

Horizontal print resolution of the device.

_pageSetupId :: Maybe Text

Relationship Id of the devMode printer settings part.

(Explicit reference to a parent XML element.)

See 22.8.2.1 "ST_RelationshipId (Explicit Relationship ID)" (p. 3784)

_pageSetupOrientation :: Maybe Orientation

Orientation of the page.

_pageSetupPageOrder :: Maybe PageOrder

Order of printed pages

_pageSetupPaperHeight :: Maybe Text

Height of custom paper as a number followed by a unit identifier.

When paperHeight and paperWidth are specified, paperSize shall be ignored. Examples: "297mm", "11in".

See 22.9.2.12 "ST_PositiveUniversalMeasure (Positive Universal Measurement)" (p. 3792)

_pageSetupPaperSize :: Maybe PaperSize

Pager size

When paperHeight, paperWidth, and paperUnits are specified, paperSize should be ignored.

_pageSetupPaperWidth :: Maybe Text

Width of custom paper as a number followed by a unit identifier

Examples: 21cm, 8.5in

When paperHeight and paperWidth are specified, paperSize shall be ignored.

_pageSetupScale :: Maybe Int

Print scaling.

This attribute is restricted to values ranging from 10 to 400. This setting is overridden when fitToWidth and/or fitToHeight are in use.

_pageSetupUseFirstPageNumber :: Maybe Bool

Use _pageSetupFirstPageNumber value for first page number, and do not auto number the pages.

_pageSetupUsePrinterDefaults :: Maybe Bool

Use the printer’s defaults settings for page setup values and don't use the default values specified in the schema.

Example: If dpi is not present or specified in the XML, the application must not assume 600dpi as specified in the schema as a default and instead must let the printer specify the default dpi.

_pageSetupVerticalDpi :: Maybe Int

Vertical print resolution of the device.

data Worksheet Source

Xlsx worksheet

Constructors

Worksheet 

Fields

_wsColumns :: [ColumnsWidth]

column widths

_wsRowPropertiesMap :: Map Int RowProperties

custom row properties (height, style) map

_wsCells :: CellMap

data mapped by (row, column) pairs

_wsMerges :: [Range]

list of cell merges

_wsSheetViews :: Maybe [SheetView]
 
_wsPageSetup :: Maybe PageSetup
 

type CellMap = Map (Int, Int) Cell Source

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 Source

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

data Cell Source

Currently cell details include only cell values and style ids (e.g. formulas from <f> and inline strings from <is> subelements are ignored)

Constructors

Cell 

type Range = Text Source

Excel range (e.g. D13:H14)

int2col :: Int -> Text Source

convert column number (starting from 1) to its textual form (e.g. 3 -> "C")

col2int :: Text -> Int Source

reverse to int2col

mkCellRef :: (Int, Int) -> CellRef Source

Render position in (row, col) format to an Excel reference.

mkCellRef (2, 4) == "D2"

mkRange :: (Int, Int) -> (Int, Int) -> Range Source

Render range

mkRange (2, 4) (6, 8) == "D2:H6"

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

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 Source

reverse to toRows