Safe Haskell | None |
---|---|
Language | Haskell2010 |
Convenience utility to read Xlsx tabular cells.
The majority of the toTableRows*
functions assume that the table
of interest consiste of contiguous rows styled with borders lines
surrounding all cells, with possible text above and below the table
that is not of interest. Like so:
Some documentation here.... --------------------------- | Header1 | Header2 | ... | --------------------------- | Value1 | Value2 | ... | --------------------------- | Value1 | Value2 | ... | --------------------------- Maybe some annoying text here, I don't care about.
The heauristic used for table row selection in these functions is that any table rows will have a bottom border line.
If the above heuristic is not valid for your table you can instead
provide your own row selection predicate to the toTableRowsCustom
function. For example, the predicate \_ _ -> True
(or (const
. const) True
) will select all contiguous rows.
- data Tabular
- data TabularHead
- data TabularRow
- tabularHeads :: Lens' Tabular [TabularHead]
- tabularRows :: Lens' Tabular [TabularRow]
- tabularHeadIx :: Lens' TabularHead Int
- tabularHeadLabel :: Lens' TabularHead Text
- tabularRowIx :: Lens' TabularRow Int
- tabularRowCells :: Lens' TabularRow [Maybe CellValue]
- def :: Default a => a
- toTableRowsFromFile :: Int -> String -> IO (Maybe Tabular)
- toTableRows :: Xlsx -> Text -> Int -> Maybe Tabular
- toTableRows' :: Xlsx -> Int -> Maybe Tabular
- toTableRowsCustom :: (StyleSheet -> (Int, [(Int, Cell)]) -> Bool) -> Xlsx -> Text -> Int -> Maybe Tabular
Types
Lenses
Tabular
tabularRows :: Lens' Tabular [TabularRow] Source #
TabularHead
TabularRow
Methods
Functions
Read tabular rows from the first sheel of an Xlsx file. The table is assumed to consist of all contiguous rows that have bottom border lines, starting with the header.
:: Xlsx | Xlsx Workbook |
-> Text | Worksheet name to decode |
-> Int | Starting row index (header row) |
-> Maybe Tabular |
Decode cells as tabular rows. The table is assumed to consist of all contiguous rows that have bottom border lines, starting with the header.
Decode cells from first sheet as tabular rows. The table is assumed to consist of all contiguous rows that have bottom border lines, starting with the header.
Custom row predicates
:: (StyleSheet -> (Int, [(Int, Cell)]) -> Bool) | Predicate for row selection |
-> Xlsx | Xlsx Workbook |
-> Text | Worksheet name to decode |
-> Int | Starting row index (header row) |
-> Maybe Tabular |
Decode cells as tabular rows. The table is assumed to consist of all contiguous rows that fulfill the given predicate, starting with the header.
The predicate function is given the Xlsx StyleSheet
as well
as a row (consisting of the row's index and the row's cells)
and should return True
if the row is part of the table.