-
-
Save qrilka/ffd9fe984e3a50fa1b0bb6c5bcd7859c to your computer and use it in GitHub Desktop.
Revisions
-
qrilka revised this gist
Dec 12, 2022 . 1 changed file with 26 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,48 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} import Codec.Xlsx as X import qualified Data.ByteString.Lazy as L import Control.Lens import Data.Time.Clock.POSIX main :: IO () main = do ct <- getPOSIXTime let name = "3" ws = X.def & X.atCell (3, 2) ?~ X.Cell (Just 1) (Just $ X.CellDouble 142.4) Nothing Nothing & X.atCell (3, 3) ?~ X.Cell (Just 2) (Just $ X.CellDouble 242.5) Nothing Nothing & X.atCell (3, 4) ?~ X.Cell (Just 3) (Just $ X.CellDouble 342.6) Nothing Nothing styleSheet = sheet where -- fill red_ = X.def & X.colorARGB ?~ "FFFF0000" fill_ = X.def & X.fillPattern ?~ ( X.def & X.fillPatternFgColor ?~ red_ & X.fillPatternType ?~ X.PatternTypeSolid ) (cellXF1 :: X.CellXf) = X.def & X.cellXfFillId ?~ 1 & X.cellXfApplyFill ?~ True (cellXF2 :: X.CellXf) = X.def & X.cellXfFillId ?~ 2 & X.cellXfApplyFill ?~ True (cellXF3 :: X.CellXf) = X.def & X.cellXfFillId ?~ 3 & X.cellXfApplyFill ?~ True sheet = X.minimalStyleSheet & styleSheetCellXfs %~ (++ [cellXF1, cellXF2,cellXF3]) & X.styleSheetFills %~ (++ [fill_, fill_]) xlsx = X.def & X.atSheet "List1" ?~ ws -
deemp revised this gist
Dec 12, 2022 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,17 +5,24 @@ example = do name = "3" ws = X.def & X.atCell (3, 2) ?~ X.Cell (Just 0) (Just $ X.CellDouble 42.0) Nothing Nothing styleSheet = sheet where -- fill red_ = X.def & X.colorARGB ?~ "ABABAB" fill_ = X.def & X.fillPattern ?~ ( X.def & X.fillPatternBgColor ?~ red_ & X.fillPatternType ?~ X.PatternTypeSolid ) (cellXF :: X.CellXf) = X.def & X.cellXfFillId ?~ 0 & X.cellXfApplyFill ?~ True & X.cellXfId ?~ 0 sheet = X.minimalStyleSheet -
deemp created this gist
Dec 11, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ example :: IO () example = do ct <- getPOSIXTime let name = "3" ws = X.def & X.atCell (1, 3) ?~ X.Cell (Just 0) (Just $ X.CellDouble 42.0) Nothing Nothing styleSheet = sheet where -- fill red_ = X.def & X.colorARGB ?~ "FFFF0000" fill_ = X.def & X.fillPattern ?~ (X.def & X.fillPatternBgColor ?~ red_) (cellXF :: X.CellXf) = X.def & X.cellXfFillId ?~ 0 & X.cellXfApplyFill ?~ True sheet = X.minimalStyleSheet & X.styleSheetCellXfs .~ [cellXF] & X.styleSheetFills .~ [fill_] xlsx = X.def & X.atSheet "List1" ?~ ws & X.xlStyles .~ X.renderStyleSheet styleSheet L.writeFile ("example-" <> name <> ".xlsx") $ X.fromXlsx ct xlsx