xlsx 0.8.2 → 0.8.3
raw patch · 6 files changed
+43/−23 lines, 6 filesdep ~lens
Dependency ranges changed: lens
Files
- CHANGELOG.markdown +7/−1
- src/Codec/Xlsx/Types.hs +2/−0
- src/Codec/Xlsx/Types/StyleSheet.hs +19/−13
- src/Codec/Xlsx/Types/Table.hs +6/−6
- src/Codec/Xlsx/Writer/Internal.hs +6/−0
- xlsx.cabal +3/−3
CHANGELOG.markdown view
@@ -1,3 +1,10 @@+0.8.3+------------+* compatibility with lens-5.0+* don't output lists with no elements in stylesheet as it causes problems in+ Excel+ (thanks to David Hewson <david.hewson@tracsis.com>)+ 0.8.2 ------ * added a flag allowing to use `microlens` instead of `lens`@@ -17,7 +24,6 @@ ----- * GHC 8.4 compatibility ------ 0.7.1 ----- * improved compatibility with Excel in pivot cache serialization
src/Codec/Xlsx/Types.hs view
@@ -217,6 +217,8 @@ , _wsSharedFormulas = M.empty } +-- | Raw worksheet styles, for structured implementation see 'StyleSheet'+-- and functions in "Codec.Xlsx.Types.StyleSheet" newtype Styles = Styles {unStyles :: L.ByteString} deriving (Eq, Show, Generic) instance NFData Styles
src/Codec/Xlsx/Types/StyleSheet.hs view
@@ -139,7 +139,7 @@ import Data.Default import Data.Map.Strict (Map) import qualified Data.Map.Strict as M-import Data.Maybe (catMaybes)+import Data.Maybe (catMaybes, maybeToList) import Data.Monoid ((<>)) import Data.Text (Text) import qualified Data.Text as T@@ -161,11 +161,11 @@ -- page numbers refer to the page in the PDF rather than the page number as -- printed on the page): ----- * Chapter 12, "SpreadsheetML" (p. 74)+-- * Chapter 12, \"SpreadsheetML\" (p. 74) -- In particular Section 12.3.20, "Styles Part" (p. 104)--- * Chapter 18, "SpreadsheetML Reference Material" (p. 1528)--- In particular Section 18.8, "Styles" (p. 1754) and Section 18.8.39--- "styleSheet" (Style Sheet)" (p. 1796); it is the latter section that+-- * Chapter 18, \"SpreadsheetML Reference Material\" (p. 1528)+-- In particular Section 18.8, \"Styles\" (p. 1754) and Section 18.8.39+-- \"styleSheet\" (Style Sheet)\" (p. 1796); it is the latter section that -- specifies the top-level style sheet format. -- -- TODO: the following child elements:@@ -176,7 +176,13 @@ -- * extLst -- * tableStyles ----- NOTE: You will probably want to base your style sheet on 'minimalStyleSheet'.+-- NOTE: Because of undocumented Excel requirements you will probably want to base+-- your style sheet on 'minimalStyleSheet' (a proper style sheet should have some+-- contents for details see+-- <https://stackoverflow.com/questions/26050708/minimal-style-sheet-for-excel-open-xml-with-dates SO post>).+-- 'def' for 'StyleSheet' includes no contents at all and this could be a problem+-- for Excel.+-- -- See also: -- -- * 'Codec.Xlsx.Types.renderStyleSheet' to translate a 'StyleSheet' to 'Styles'@@ -1142,18 +1148,18 @@ instance ToElement StyleSheet where toElement nm StyleSheet{..} = elementListSimple nm elements where- elements = [ countedElementList "numFmts" $ map (toElement "numFmt") numFmts- , countedElementList "fonts" $ map (toElement "font") _styleSheetFonts- , countedElementList "fills" $ map (toElement "fill") _styleSheetFills- , countedElementList "borders" $ map (toElement "border") _styleSheetBorders+ countedElementList' nm' xs = maybeToList $ nonEmptyCountedElementList nm' xs+ elements = countedElementList' "numFmts" (map (toElement "numFmt") numFmts) +++ countedElementList' "fonts" (map (toElement "font") _styleSheetFonts) +++ countedElementList' "fills" (map (toElement "fill") _styleSheetFills) +++ countedElementList' "borders" (map (toElement "border") _styleSheetBorders) ++ -- TODO: cellStyleXfs- , countedElementList "cellXfs" $ map (toElement "xf") _styleSheetCellXfs+ countedElementList' "cellXfs" (map (toElement "xf") _styleSheetCellXfs) ++ -- TODO: cellStyles- , countedElementList "dxfs" $ map (toElement "dxf") _styleSheetDxfs+ countedElementList' "dxfs" (map (toElement "dxf") _styleSheetDxfs) -- TODO: tableStyles -- TODO: colors -- TODO: extLst- ] numFmts = map (uncurry NumFmt) $ M.toList _styleSheetNumFmts -- | See @CT_Xf@, p. 4486
src/Codec/Xlsx/Types/Table.hs view
@@ -118,9 +118,9 @@ ] subElements = maybeToList (toElement "autoFilter" <$> tblAutoFilter) ++- [ countedElementList- "tableColumns"- [ leafElement "tableColumn" ["id" .= i', "name" .= tblcName c]- | (i', c) <- zip [(1 :: Int) ..] tblColumns- ]- ]+ maybeToList (nonEmptyCountedElementList+ "tableColumns"+ [ leafElement "tableColumn" ["id" .= i', "name" .= tblcName c]+ | (i', c) <- zip [(1 :: Int) ..] tblColumns+ ]+ )
src/Codec/Xlsx/Writer/Internal.hs view
@@ -12,6 +12,7 @@ -- * Rendering elements , ToElement(..) , countedElementList+ , nonEmptyCountedElementList , elementList , elementListSimple , nonEmptyElListSimple@@ -85,6 +86,11 @@ countedElementList :: Name -> [Element] -> Element countedElementList nm as = elementList nm [ "count" .= length as ] as++nonEmptyCountedElementList :: Name -> [Element] -> Maybe Element+nonEmptyCountedElementList nm as = case as of+ [] -> Nothing+ _ -> Just $ countedElementList nm as elementList :: Name -> [(Name, Text)] -> [Element] -> Element elementList nm attrs els = Element {
xlsx.cabal view
@@ -1,6 +1,6 @@ Name: xlsx -Version: 0.8.2+Version: 0.8.3 Synopsis: Simple and incomplete Excel file parser/writer Description:@@ -108,7 +108,7 @@ , microlens-th cpp-options: -DUSE_MICROLENS else- Build-depends: lens >= 3.8 && < 5+ Build-depends: lens >= 3.8 && < 5.1 Default-Language: Haskell2010 Other-Extensions: DeriveDataTypeable@@ -137,7 +137,7 @@ , containers , Diff >= 0.3.0 , groom- , lens >= 3.8 && < 5+ , lens >= 3.8 && < 5.1 , mtl , raw-strings-qq , smallcheck