Example #1
0
        public void Bug47668()
        {
            XSSFWorkbook workbook    = XSSFTestDataSamples.OpenSampleWorkbook("47668.xlsx");
            IList        allPictures = workbook.GetAllPictures();

            Assert.AreEqual(1, allPictures.Count);

            PackagePartName imagePartName = PackagingUriHelper
                                            .CreatePartName("/xl/media/image1.jpeg");
            PackagePart imagePart = workbook.Package.GetPart(imagePartName);

            Assert.IsNotNull(imagePart);

            foreach (XSSFPictureData pictureData in allPictures)
            {
                PackagePart picturePart = pictureData.GetPackagePart();
                Assert.AreSame(imagePart, picturePart);
            }

            XSSFSheet       sheet0       = (XSSFSheet)workbook.GetSheetAt(0);
            XSSFDrawing     Drawing0     = (XSSFDrawing)sheet0.CreateDrawingPatriarch();
            XSSFPictureData pictureData0 = (XSSFPictureData)Drawing0.GetRelations()[0];

            byte[] data0 = pictureData0.Data;
            CRC32  crc0  = new CRC32();

            crc0.Update(data0);

            XSSFSheet       sheet1       = workbook.GetSheetAt(1) as XSSFSheet;
            XSSFDrawing     Drawing1     = sheet1.CreateDrawingPatriarch() as XSSFDrawing;
            XSSFPictureData pictureData1 = (XSSFPictureData)Drawing1.GetRelations()[0];

            byte[] data1 = pictureData1.Data;
            CRC32  crc1  = new CRC32();

            crc1.Update(data1);

            Assert.AreEqual(crc0.Value, crc1.Value);
            workbook.Close();
        }