xlsx-1.0.0.1: Simple and incomplete Excel file parser/writer
Safe HaskellNone
LanguageHaskell2010

Codec.Xlsx.Writer.Stream

Description

Writes Excel files from a stream, which allows creation of large Excel files while remaining in constant memory.

Synopsis

Documentation

writeXlsx Source #

Arguments

:: MonadThrow m 
=> PrimMonad m 
=> SheetWriteSettings

use defaultSettings

-> 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 #

Arguments

:: 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,

  1. Every text to int is unique on both text and int.
  2. Every Int should have a gap no greater than 1. [("xx", 3), ("yy", 4)] is okay, whereas [("xx", 3), ("yy", 5)] is not.
  3. 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.

Constructors

MkSheetWriteSettings 

Fields

Instances

Instances details
Show SheetWriteSettings Source # 
Instance details

Defined in Codec.Xlsx.Writer.Stream

wsZip :: Lens' SheetWriteSettings ZipOptions Source #

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