HExcel: Create Excel files with Haskell

[ Excel, bsd3, data, library, spreadsheet, text ] [ Propose Tags ]

Easily create Excel files with Haskell. See README at https://github.com/green-lambda/HExcel

[Skip to Readme]
Versions [RSS] [faq],
Change log CHANGELOG.md
Dependencies base (>=4.5 && <4.13), microlens, microlens-th, time, transformers [details]
License BSD-3-Clause
Author Sasha Bogicevic
Maintainer sasa.bogicevic@pm.me
Category Data, Text, SpreadSheet
Uploaded by v0d1ch at 2019-06-24T19:56:41Z
Distributions NixOS:
Downloads 693 total (14 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]




Maintainer's Corner

For package maintainers and hackage trustees


Readme for HExcel-

[back to package description]


Create Excel files with Haskell

This is a fork of libxlsxwriter that tries the improve on the api and provide a library for creation of Excel files. Underneath the hood it uses C library called libxlsxwriter and provides bindings to C code to produce Excel 2007+ xlsx files.


{-# 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"
		 -- or 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