Skip to content

Instantly share code, notes, and snippets.

@qrilka
Created April 11, 2016 05:59
Show Gist options
  • Select an option

  • Save qrilka/15ce862e18fd1d13f58e1677c3f307f3 to your computer and use it in GitHub Desktop.

Select an option

Save qrilka/15ce862e18fd1d13f58e1677c3f307f3 to your computer and use it in GitHub Desktop.

Revisions

  1. qrilka created this gist Apr 11, 2016.
    16 changes: 16 additions & 0 deletions Xlsx example for Jyrki
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    {-# LANGUAGE OverloadedStrings #-}
    import Data.ByteString.Lazy as L hiding (putStrLn)
    import Codec.Xlsx
    import Control.Lens
    import Data.Time.Clock.POSIX (getPOSIXTime)

    main = do
    bs <- L.readFile "test.xlsx"
    let
    xlsx0 = toXlsx bs
    value = xlsx0 ^? ixSheet "4_pooli" . ixCell (2,2) . cellValue . _Just
    ct <- getPOSIXTime
    putStrLn $ "Cell B2 contains " ++ show value
    let
    xlsx = xlsx0 & atSheet "sheet" . _Just . cellValueAt (2,2) ?~ CellText "New text"
    L.writeFile "example.xlsx" $ fromXlsx ct xlsx