packages feed

xlsx 1.1.3 → 1.1.4

raw patch · 5 files changed

+32/−11 lines, 5 filesbinary-added

Files

CHANGELOG.markdown view
@@ -1,3 +1,8 @@+1.1.4+------------+* fix the problem with leading slashes for comments, drawings and pivot tables+  (thanks to  mindston <mindston@eml.cc>)+ 1.1.3 ------------ * fixed compatibility with xml-conduit moving `rsPretty` into internal module
+ data/absolute_relationships.xlsx view

binary file changed (absent → 6869 bytes)

src/Codec/Xlsx/Parser.hs view
@@ -214,8 +214,8 @@        let commentsType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"           commentTarget :: Maybe FilePath-          commentTarget = relTarget <$> findRelByType commentsType sheetRels-          legacyDrPath = fmap relTarget . flip Relationships.lookup sheetRels =<< legacyDrRId+          commentTarget = logicalNameToZipItemName . relTarget <$> findRelByType commentsType sheetRels+          legacyDrPath = fmap (logicalNameToZipItemName . relTarget) . flip Relationships.lookup sheetRels =<< legacyDrRId       commentsMap <-         fmap join . forM commentTarget $ getComments ar legacyDrPath       let commentCells =@@ -230,11 +230,11 @@         fp <- lookupRelPath filePath sheetRels rId         getTable ar fp       drawing <- forM drawingRId $ \dId -> do-        rel <- note (InvalidRef filePath dId) $ Relationships.lookup dId sheetRels-        getDrawing ar contentTypes (relTarget rel)+        fp <- lookupRelPath filePath sheetRels dId+        getDrawing ar contentTypes fp       let ptType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"       pivotTables <- forM (allByType ptType sheetRels) $ \rel -> do-        let ptPath = relTarget rel+        let ptPath = logicalNameToZipItemName $ relTarget rel         bs <- note (MissingFile ptPath) $ Zip.fromEntry <$> Zip.findEntryByPath ptPath ar         note (InconsistentXlsx $ "Bad pivot table in " <> T.pack ptPath) $           parsePivotTable (flip Prelude.lookup caches) bs@@ -369,9 +369,9 @@    let commentsType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"       commentTarget :: Maybe FilePath-      commentTarget = relTarget <$> findRelByType commentsType sheetRels+      commentTarget = logicalNameToZipItemName . relTarget <$> findRelByType commentsType sheetRels       legacyDrRId = cur $/ element (n_ "legacyDrawing") >=> fromAttribute (odr"id")-      legacyDrPath = fmap relTarget . flip Relationships.lookup sheetRels  =<< listToMaybe legacyDrRId+      legacyDrPath = fmap (logicalNameToZipItemName . relTarget) . flip Relationships.lookup sheetRels  =<< listToMaybe legacyDrRId    commentsMap :: Maybe CommentTable <- maybe (Right Nothing) (getComments ar legacyDrPath) commentTarget @@ -470,14 +470,14 @@    mDrawing <- case mDrawingId of       Just dId -> do-          rel <- note (InvalidRef filePath dId) $ Relationships.lookup dId sheetRels-          Just <$> getDrawing ar contentTypes (relTarget rel)+          fp <- lookupRelPath filePath sheetRels dId+          Just <$> getDrawing ar contentTypes fp       Nothing  ->           return Nothing    let ptType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"   pTables <- forM (allByType ptType sheetRels) $ \rel -> do-    let ptPath = relTarget rel+    let ptPath = logicalNameToZipItemName $ relTarget rel     bs <- note (MissingFile ptPath) $ Zip.fromEntry <$> Zip.findEntryByPath ptPath ar     note (InconsistentXlsx $ "Bad pivot table in " <> T.pack ptPath) $       parsePivotTable (flip Prelude.lookup caches) bs
test/Main.hs view
@@ -81,6 +81,10 @@         $ floatsParsingTests toXlsx     , testCase "toXlsxFast: correct floats parsing (typed and untyped cells are floats by default)"         $ floatsParsingTests toXlsxFast+    , testCase "toXlsx: correct resolving of absolute relationship targets"+        $ absoluteRelationshipsTest toXlsx+    , testCase "toXlsxFast: correct resolving of absolute relationship targets"+        $ absoluteRelationshipsTest toXlsxFast     , testGroup "Codec: sheet state visibility"         [ testGroup "toXlsxEitherFast"             [ testProperty "pure state == toXlsxEitherFast (fromXlsx (defXlsxWithState state))" $@@ -123,6 +127,17 @@         , ((4,1), def & cellValue ?~ CellDouble 15.0)         ]   expectedCells @==? parsedCells++-- Test whether absolute logical item names are correctly mapped to ZIP item names.+-- absolute_relationships.xlsx contains relationships of worksheet, comment,+-- drawing and pivot table types with absolute paths in their targets.+absoluteRelationshipsTest :: (ByteString -> Xlsx) -> IO ()+absoluteRelationshipsTest parser = do+  bs <- LB.readFile "data/absolute_relationships.xlsx"+  let xlsx = parser bs+      expectedComment = Just $ Comment (XlsxText "test comment") "author" False+      parsedComment = xlsx ^? ixSheet "Test" . ixCell (2, 1) . cellComment . _Just+  expectedComment @==? parsedComment  constSheetName :: Text constSheetName = "sheet1"
xlsx.cabal view
@@ -1,6 +1,6 @@ Name:                xlsx -Version:             1.1.3+Version:             1.1.4  Synopsis:            Simple and incomplete Excel file parser/writer Description:@@ -17,6 +17,7 @@                      CHANGELOG.markdown                      data/inline-strings.xlsx                      data/floats.xlsx+                     data/absolute_relationships.xlsx  Homepage:            https://github.com/qrilka/xlsx Bug-Reports:         https://github.com/qrilka/xlsx/issues