module Codec.Xlsx.Types.Internal.CfPair where
import Text.XML.Cursor
import Codec.Xlsx.Parser.Internal
import Codec.Xlsx.Types.Common
import Codec.Xlsx.Types.ConditionalFormatting
import Codec.Xlsx.Writer.Internal
newtype CfPair = CfPair
{ unCfPair :: (SqRef, ConditionalFormatting)
} deriving (Eq, Show)
instance FromCursor CfPair where
fromCursor cur = do
sqref <- fromAttribute "sqref" cur
let cfRules = cur $/ element (n"cfRule") >=> fromCursor
return $ CfPair (sqref, cfRules)
instance ToElement CfPair where
toElement nm (CfPair (sqRef, cfRules)) =
elementList nm [ "sqref" .= toAttrVal sqRef ]
(map (toElement "cfRule") cfRules)