module Codec.Xlsx.Types.Internal.DvPair where
import qualified Data.Map as M
import Text.XML (Element (..))
import Codec.Xlsx.Parser.Internal
import Codec.Xlsx.Types.Common
import Codec.Xlsx.Types.DataValidation
import Codec.Xlsx.Writer.Internal
newtype DvPair = DvPair
{ unDvPair :: (SqRef, DataValidation)
} deriving (Eq, Show)
instance FromCursor DvPair where
fromCursor cur = do
sqref <- fromAttribute "sqref" cur
dv <- fromCursor cur
return $ DvPair (sqref, dv)
instance ToElement DvPair where
toElement nm (DvPair (sqRef,dv)) = e
{elementAttributes = M.insert "sqref" (toAttrVal sqRef) $ elementAttributes e}
where
e = toElement nm dv