Maintainer | Sasha Bogicevic <sasa.bogicevic@pm.me> |
---|---|
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Module exports
Example usage:
{-# LANGUAGE TypeApplications #-} module Main where import Control.Monad.Trans.State (execStateT) import Control.Monad (forM_) import Data.Time (getZonedTime) import HExcel main :: IO () main = do wb <- workbookNew "test.xlsx" let props = mkDocProperties { docPropertiesTitle = "Test Workbook" , docPropertiesCompany = "HExcel" } workbookSetProperties wb props ws <- workbookAddWorksheet wb "First Sheet" df <- workbookAddFormat wb formatSetNumFormat df "mmm d yyyy hh:mm AM/PM" now <- getZonedTime -- You can create HExcelState which is convenient api for writing to cells let initState = HExcelState Nothing ws 4 1 0 1 0 _ <- flip execStateT initState $ do writeCell "David" writeCell "Dimitrije" -- we can skip some rows skipRows 1 writeCell "Jovana" -- skip some columns skipCols 1 writeCell (zonedTimeToDateTime now) writeCell @Double 42.5 -- or use functions that run in plain IO forM_ [5 .. 8] $ \n -> do writeString ws Nothing n 3 "xxx" writeNumber ws Nothing n 4 1234.56 writeDateTime ws (Just df) n 5 (zonedTimeToDateTime now) workbookClose wb
Synopsis
- data Workbook
- workbookNew :: FilePath -> IO Workbook
- workbookNewConstantMem :: FilePath -> IO Workbook
- workbookClose :: Workbook -> IO ()
- workbookAddWorksheet :: Workbook -> String -> IO Worksheet
- workbookAddFormat :: Workbook -> IO Format
- workbookDefineName :: Workbook -> String -> String -> IO ()
- data DocProperties = DocProperties {
- docPropertiesTitle :: String
- docPropertiesSubject :: String
- docPropertiesAuthor :: String
- docPropertiesManager :: String
- docPropertiesCompany :: String
- docPropertiesCategory :: String
- docPropertiesKeywords :: String
- docPropertiesComments :: String
- docPropertiesStatus :: String
- docPropertiesHyperlinkBase :: String
- docPropertiesCreated :: UTCTime
- workbookSetProperties :: Workbook -> DocProperties -> IO ()
- data Worksheet
- type Row = Word32
- type Col = Word16
- writeNumber :: Worksheet -> Maybe Format -> Row -> Col -> Double -> IO ()
- writeString :: Worksheet -> Maybe Format -> Row -> Col -> String -> IO ()
- writeUTCTime :: Worksheet -> Maybe Format -> Row -> Col -> UTCTime -> IO ()
- writeFormula :: Worksheet -> Maybe Format -> Row -> Col -> String -> IO ()
- writeArrayFormula :: Worksheet -> Maybe Format -> Row -> Col -> Row -> Col -> String -> IO ()
- data DateTime = DateTime {}
- utcTimeToDateTime :: UTCTime -> DateTime
- zonedTimeToDateTime :: ZonedTime -> DateTime
- writeDateTime :: Worksheet -> Maybe Format -> Row -> Col -> DateTime -> IO ()
- writeUrl :: Worksheet -> Maybe Format -> Row -> Col -> String -> IO ()
- worksheetSetRow :: Worksheet -> Maybe Format -> Row -> Double -> IO ()
- worksheetSetColumn :: Worksheet -> Maybe Format -> Col -> Col -> Double -> IO ()
- data ImageOptions = ImageOptions {}
- worksheetInsertImage :: Worksheet -> Word32 -> Word16 -> String -> IO ()
- worksheetInsertImageOpt :: Worksheet -> Row -> Col -> FilePath -> ImageOptions -> IO ()
- worksheetMergeRange :: Worksheet -> Maybe Format -> Row -> Col -> Row -> Col -> String -> IO ()
- worksheetFreezePanes :: Worksheet -> Row -> Col -> IO ()
- worksheetSplitPanes :: Worksheet -> Double -> Double -> IO ()
- worksheetSetLandscape :: Worksheet -> IO ()
- worksheetSetPortrait :: Worksheet -> IO ()
- worksheetSetPageView :: Worksheet -> IO ()
- data PaperSize
- skipCols :: MonadIO m => Word16 -> StateT HExcelState m ()
- skipRows :: MonadIO m => Word32 -> StateT HExcelState m ()
- worksheetSetPaperSize :: Worksheet -> PaperSize -> IO ()
- worksheetSetMargins :: Worksheet -> Double -> Double -> Double -> Double -> IO ()
- worksheetSetHeaderCtl :: Worksheet -> String -> IO ()
- worksheetSetFooterCtl :: Worksheet -> String -> IO ()
- worksheetSetZoom :: Worksheet -> Double -> IO ()
- worksheetSetPrintScale :: Worksheet -> Double -> IO ()
- data Format
- formatSetFontName :: Format -> String -> IO ()
- formatSetFontSize :: Format -> Word16 -> IO ()
- data Color
- formatSetFontColor :: Format -> Color -> IO ()
- formatSetNumFormat :: Format -> String -> IO ()
- formatSetBold :: Format -> IO ()
- formatSetItalic :: Format -> IO ()
- data UnderlineStyle
- formatSetUnderline :: Format -> UnderlineStyle -> IO ()
- formatSetStrikeout :: Format -> IO ()
- data ScriptStyle
- formatSetScript :: Format -> ScriptStyle -> IO ()
- formatSetBuiltInFormat :: Format -> Word8 -> IO ()
- data Align
- data VerticalAlign
- formatSetAlign :: Format -> Align -> IO ()
- formatSetVerticalAlign :: Format -> VerticalAlign -> IO ()
- formatSetTextWrap :: Format -> IO ()
- formatSetRotation :: Format -> Int -> IO ()
- formatSetShrink :: Format -> IO ()
- data Pattern
- = PatternNone
- | PatternSolid
- | PatternMediumGray
- | PatternDarkGray
- | PatternLightGray
- | PatternDarkHorizontal
- | PatternDarkVertical
- | PatternDarkDown
- | PatternDarkUp
- | PatternDarkGrid
- | PatternDarkTrellis
- | PatternLightHorizontal
- | PatternLightVertical
- | PatternLightDown
- | PatternLightUp
- | PatternLightGrid
- | PatternLightTrellis
- | PatternGray125
- | PatternGray0625
- formatSetPattern :: Format -> Pattern -> IO ()
- formatSetBackgroundColor :: Format -> Color -> IO ()
- formatSetForegroundColor :: Format -> Color -> IO ()
- data Border
- data BorderStyle
- formatSetBorder :: Format -> Border -> BorderStyle -> IO ()
- formatSetBorderColor :: Format -> Border -> Color -> IO ()
- data HExcelState = HExcelState {}
- class HExcel a where
- writeCell :: MonadIO m => a -> StateT HExcelState m ()
- mkDocProperties :: DocProperties
Documentation
workbookNewConstantMem :: FilePath -> IO Workbook Source #
Create new workbook but force constant memory. It reduces the amount of data stored in memory so that large files can be written efficiently.
workbookClose :: Workbook -> IO () Source #
Close the workbook
data DocProperties Source #
Excel document properties
workbookSetProperties :: Workbook -> DocProperties -> IO () Source #
Set workbook properties
writeNumber :: Worksheet -> Maybe Format -> Row -> Col -> Double -> IO () Source #
Write a Double
value to Excel cell
writeString :: Worksheet -> Maybe Format -> Row -> Col -> String -> IO () Source #
Write a String
value to Excel cell
writeUTCTime :: Worksheet -> Maybe Format -> Row -> Col -> UTCTime -> IO () Source #
Write a UTCTime
value to Excel cell
writeFormula :: Worksheet -> Maybe Format -> Row -> Col -> String -> IO () Source #
Write a formula to Excel cell
writeArrayFormula :: Worksheet -> Maybe Format -> Row -> Col -> Row -> Col -> String -> IO () Source #
Type to hold datetime values
Instances
Show DateTime Source # | |
Storable DateTime Source # | |
HExcel DateTime Source # | |
Defined in HExcel.HExcelInternal |
writeDateTime :: Worksheet -> Maybe Format -> Row -> Col -> DateTime -> IO () Source #
Write a DateTime
to Excel cell
writeUrl :: Worksheet -> Maybe Format -> Row -> Col -> String -> IO () Source #
Write a url to Excel cell
worksheetSetColumn :: Worksheet -> Maybe Format -> Col -> Col -> Double -> IO () Source #
Set worksheet column
data ImageOptions Source #
Type to hold image options
ImageOptions | |
|
Instances
Storable ImageOptions Source # | |
Defined in HExcel.Types sizeOf :: ImageOptions -> Int # alignment :: ImageOptions -> Int # peekElemOff :: Ptr ImageOptions -> Int -> IO ImageOptions # pokeElemOff :: Ptr ImageOptions -> Int -> ImageOptions -> IO () # peekByteOff :: Ptr b -> Int -> IO ImageOptions # pokeByteOff :: Ptr b -> Int -> ImageOptions -> IO () # peek :: Ptr ImageOptions -> IO ImageOptions # poke :: Ptr ImageOptions -> ImageOptions -> IO () # |
worksheetInsertImage :: Worksheet -> Word32 -> Word16 -> String -> IO () Source #
Insert image to worksheet
worksheetInsertImageOpt :: Worksheet -> Row -> Col -> FilePath -> ImageOptions -> IO () Source #
worksheetMergeRange :: Worksheet -> Maybe Format -> Row -> Col -> Row -> Col -> String -> IO () Source #
Merge columns
worksheetSetLandscape :: Worksheet -> IO () Source #
Set worksheet to Landscape
worksheetSetPortrait :: Worksheet -> IO () Source #
Set worksheet to Portrait
worksheetSetPageView :: Worksheet -> IO () Source #
Paper size
worksheetSetMargins :: Worksheet -> Double -> Double -> Double -> Double -> IO () Source #
Set worksheet margins
Colors
formatSetBold :: Format -> IO () Source #
Set bold style
formatSetItalic :: Format -> IO () Source #
Set italic style
data UnderlineStyle Source #
Underline styles
Instances
Enum UnderlineStyle Source # | |
Defined in HExcel.Types succ :: UnderlineStyle -> UnderlineStyle # pred :: UnderlineStyle -> UnderlineStyle # toEnum :: Int -> UnderlineStyle # fromEnum :: UnderlineStyle -> Int # enumFrom :: UnderlineStyle -> [UnderlineStyle] # enumFromThen :: UnderlineStyle -> UnderlineStyle -> [UnderlineStyle] # enumFromTo :: UnderlineStyle -> UnderlineStyle -> [UnderlineStyle] # enumFromThenTo :: UnderlineStyle -> UnderlineStyle -> UnderlineStyle -> [UnderlineStyle] # | |
Eq UnderlineStyle Source # | |
Defined in HExcel.Types (==) :: UnderlineStyle -> UnderlineStyle -> Bool # (/=) :: UnderlineStyle -> UnderlineStyle -> Bool # | |
Read UnderlineStyle Source # | |
Defined in HExcel.Types readsPrec :: Int -> ReadS UnderlineStyle # readList :: ReadS [UnderlineStyle] # | |
Show UnderlineStyle Source # | |
Defined in HExcel.Types showsPrec :: Int -> UnderlineStyle -> ShowS # show :: UnderlineStyle -> String # showList :: [UnderlineStyle] -> ShowS # |
formatSetUnderline :: Format -> UnderlineStyle -> IO () Source #
Set underline style
formatSetStrikeout :: Format -> IO () Source #
data ScriptStyle Source #
Script styles
Instances
Enum ScriptStyle Source # | |
Defined in HExcel.Types succ :: ScriptStyle -> ScriptStyle # pred :: ScriptStyle -> ScriptStyle # toEnum :: Int -> ScriptStyle # fromEnum :: ScriptStyle -> Int # enumFrom :: ScriptStyle -> [ScriptStyle] # enumFromThen :: ScriptStyle -> ScriptStyle -> [ScriptStyle] # enumFromTo :: ScriptStyle -> ScriptStyle -> [ScriptStyle] # enumFromThenTo :: ScriptStyle -> ScriptStyle -> ScriptStyle -> [ScriptStyle] # | |
Eq ScriptStyle Source # | |
Defined in HExcel.Types (==) :: ScriptStyle -> ScriptStyle -> Bool # (/=) :: ScriptStyle -> ScriptStyle -> Bool # | |
Read ScriptStyle Source # | |
Defined in HExcel.Types readsPrec :: Int -> ReadS ScriptStyle # readList :: ReadS [ScriptStyle] # readPrec :: ReadPrec ScriptStyle # readListPrec :: ReadPrec [ScriptStyle] # | |
Show ScriptStyle Source # | |
Defined in HExcel.Types showsPrec :: Int -> ScriptStyle -> ShowS # show :: ScriptStyle -> String # showList :: [ScriptStyle] -> ShowS # |
formatSetScript :: Format -> ScriptStyle -> IO () Source #
Alignment styles
AlignNone | |
AlignLeft | |
AlignCenter | |
AlignRight | |
AlignFill | |
AlignJustify | |
AlignCenterAcross | |
AlignDistributed |
data VerticalAlign Source #
Vertical align styles
VerticalAlignNone | |
VerticalAlignTop | |
VerticalAlignBottom | |
VerticalAlignCenter | |
VerticalAlignJustify | |
VerticalAlignDistributed |
Instances
Enum VerticalAlign Source # | |
Defined in HExcel.Types succ :: VerticalAlign -> VerticalAlign # pred :: VerticalAlign -> VerticalAlign # toEnum :: Int -> VerticalAlign # fromEnum :: VerticalAlign -> Int # enumFrom :: VerticalAlign -> [VerticalAlign] # enumFromThen :: VerticalAlign -> VerticalAlign -> [VerticalAlign] # enumFromTo :: VerticalAlign -> VerticalAlign -> [VerticalAlign] # enumFromThenTo :: VerticalAlign -> VerticalAlign -> VerticalAlign -> [VerticalAlign] # | |
Eq VerticalAlign Source # | |
Defined in HExcel.Types (==) :: VerticalAlign -> VerticalAlign -> Bool # (/=) :: VerticalAlign -> VerticalAlign -> Bool # | |
Read VerticalAlign Source # | |
Defined in HExcel.Types readsPrec :: Int -> ReadS VerticalAlign # readList :: ReadS [VerticalAlign] # | |
Show VerticalAlign Source # | |
Defined in HExcel.Types showsPrec :: Int -> VerticalAlign -> ShowS # show :: VerticalAlign -> String # showList :: [VerticalAlign] -> ShowS # |
formatSetVerticalAlign :: Format -> VerticalAlign -> IO () Source #
formatSetTextWrap :: Format -> IO () Source #
formatSetShrink :: Format -> IO () Source #
Pattern styles
Instances
Enum Pattern Source # | |
Eq Pattern Source # | |
Read Pattern Source # | |
Show Pattern Source # | |
data BorderStyle Source #
Border styles
Instances
Enum BorderStyle Source # | |
Defined in HExcel.Types succ :: BorderStyle -> BorderStyle # pred :: BorderStyle -> BorderStyle # toEnum :: Int -> BorderStyle # fromEnum :: BorderStyle -> Int # enumFrom :: BorderStyle -> [BorderStyle] # enumFromThen :: BorderStyle -> BorderStyle -> [BorderStyle] # enumFromTo :: BorderStyle -> BorderStyle -> [BorderStyle] # enumFromThenTo :: BorderStyle -> BorderStyle -> BorderStyle -> [BorderStyle] # | |
Eq BorderStyle Source # | |
Defined in HExcel.Types (==) :: BorderStyle -> BorderStyle -> Bool # (/=) :: BorderStyle -> BorderStyle -> Bool # | |
Read BorderStyle Source # | |
Defined in HExcel.Types readsPrec :: Int -> ReadS BorderStyle # readList :: ReadS [BorderStyle] # readPrec :: ReadPrec BorderStyle # readListPrec :: ReadPrec [BorderStyle] # | |
Show BorderStyle Source # | |
Defined in HExcel.Types showsPrec :: Int -> BorderStyle -> ShowS # show :: BorderStyle -> String # showList :: [BorderStyle] -> ShowS # |
formatSetBorder :: Format -> Border -> BorderStyle -> IO () Source #
data HExcelState Source #
HExcelState
is the state we thread trough for the writeCell function of the
HExcel typeclass. We are trying to create a convenient api for writing cell values
without too much hassle.
HExcelState | |
|
HExcel class that provides a single function writeCell
as a convenient method
of writing excel cell values
Instances
HExcel Double Source # | |
Defined in HExcel.HExcelInternal | |
HExcel Float Source # | |
Defined in HExcel.HExcelInternal | |
HExcel Int Source # | |
Defined in HExcel.HExcelInternal | |
HExcel Integer Source # | |
Defined in HExcel.HExcelInternal | |
HExcel Word Source # | |
Defined in HExcel.HExcelInternal | |
HExcel String Source # | |
Defined in HExcel.HExcelInternal | |
HExcel UTCTime Source # | |
Defined in HExcel.HExcelInternal | |
HExcel DateTime Source # | |
Defined in HExcel.HExcelInternal |