Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Writes Excel files from a stream, which allows creation of large Excel files while remaining in constant memory.
Synopsis
- writeXlsx :: MonadThrow m => PrimMonad m => SheetWriteSettings -> ConduitT () Row m () -> ConduitT () ByteString m Word64
- writeXlsxWithSharedStrings :: MonadThrow m => PrimMonad m => SheetWriteSettings -> Map Text Int -> ConduitT () Row m () -> ConduitT () ByteString m Word64
- data SheetWriteSettings = MkSheetWriteSettings {}
- defaultSettings :: SheetWriteSettings
- wsSheetView :: Lens' SheetWriteSettings [SheetView]
- wsZip :: Lens' SheetWriteSettings ZipOptions
- wsColumnProperties :: Lens' SheetWriteSettings [ColumnsProperties]
- wsRowProperties :: Lens' SheetWriteSettings (Map Int RowProperties)
- wsStyles :: Lens' SheetWriteSettings Styles
- sharedStrings :: Monad m => ConduitT Row b m (Map Text Int)
- sharedStringsStream :: Monad m => ConduitT Row (Text, Int) m (Map Text Int)
Documentation
:: MonadThrow m | |
=> PrimMonad m | |
=> SheetWriteSettings | use |
-> ConduitT () Row m () | the conduit producing sheetitems |
-> ConduitT () ByteString m Word64 | result conduit producing xlsx files |
Transform a Row
stream into a stream that creates the xlsx file format
(to be consumed by sinkfile for example)
This first runs sharedStrings
and then writeXlsxWithSharedStrings
.
If you want xlsx files this is the most obvious function to use.
the others are exposed in case you can cache the shared strings for example.
Note that the current implementation concatenates everything into a single sheet. In other words there is no support for writing multiple sheets
writeXlsxWithSharedStrings Source #
:: MonadThrow m | |
=> PrimMonad m | |
=> SheetWriteSettings | |
-> Map Text Int | shared strings table |
-> ConduitT () Row m () | |
-> ConduitT () ByteString m Word64 |
This write Excel file with a shared strings lookup table. It appears that it is optional. Failed lookups will result in valid xlsx. There are several conditions on shared strings,
- Every text to int is unique on both text and int.
- Every Int should have a gap no greater than 1. [("xx", 3), ("yy", 4)] is okay, whereas [("xx", 3), ("yy", 5)] is not.
- It's expected this starts from 0.
Use sharedStringsStream
to get a good shared strings table.
This is provided because the user may have a more efficient way of
constructing this table than the library can provide,
for example through database operations.
data SheetWriteSettings Source #
Settings for writing a single sheet.
MkSheetWriteSettings | |
|
Instances
Show SheetWriteSettings Source # | |
Defined in Codec.Xlsx.Writer.Stream showsPrec :: Int -> SheetWriteSettings -> ShowS # show :: SheetWriteSettings -> String # showList :: [SheetWriteSettings] -> ShowS # |
Shared strings
sharedStrings :: Monad m => ConduitT Row b m (Map Text Int) Source #
Process sheetItems into shared strings structure to be put into
writeXlsxWithSharedStrings
sharedStringsStream :: Monad m => ConduitT Row (Text, Int) m (Map Text Int) Source #
creates a unique number for every encountered string in the stream This is used for creating a required structure in the xlsx format called shared strings. Every string get's transformed into a number
exposed to allow further processing, we also know the map after processing
but I don't think conduit provides a way of getting that out.
use sharedStrings
to just get the map