コード例 #1
0
ファイル: TestPOIXMLDocument.cs プロジェクト: zzy092/npoi
        public void TestPPTX()
        {
            POIDataSamples pds = POIDataSamples.GetSlideShowInstance();

            AssertReadWrite(
                PackageHelper.Open(pds.OpenResourceAsStream("PPTWithAttachments.pptm"))
                );
        }
コード例 #2
0
ファイル: TestOLE2Embeding.cs プロジェクト: hiodava/Romero
        static POIFSFileSystem GetSamplePPT()
        {
            // scratchpad classes are not available, so we use something pre-cooked
            Stream          is1   = POIDataSamples.GetSlideShowInstance().OpenResourceAsStream("with_textbox.ppt");
            POIFSFileSystem poifs = new POIFSFileSystem(is1);

            is1.Close();

            return(poifs);
        }
コード例 #3
0
        public void Test49658()
        {
            // test if inserted EscherMetafileBlip will be read again
            IWorkbook wb = new HSSFWorkbook();

            byte[] pictureDataEmf = POIDataSamples.GetDocumentInstance().ReadFile("vector_image.emf");
            int    indexEmf       = wb.AddPicture(pictureDataEmf, PictureType.EMF);

            byte[] pictureDataPng = POIDataSamples.GetSpreadSheetInstance().ReadFile("logoKarmokar4.png");
            int    indexPng       = wb.AddPicture(pictureDataPng, PictureType.PNG);

            byte[] pictureDataWmf = POIDataSamples.GetSlideShowInstance().ReadFile("santa.wmf");
            int    indexWmf       = wb.AddPicture(pictureDataWmf, PictureType.WMF);

            ISheet          sheet     = wb.CreateSheet();
            HSSFPatriarch   patriarch = sheet.CreateDrawingPatriarch() as HSSFPatriarch;
            ICreationHelper ch        = wb.GetCreationHelper();

            IClientAnchor anchor = ch.CreateClientAnchor();

            anchor.Col1 = (/*setter*/ 2);
            anchor.Col2 = (/*setter*/ 5);
            anchor.Row1 = (/*setter*/ 1);
            anchor.Row2 = (/*setter*/ 6);
            patriarch.CreatePicture(anchor, indexEmf);

            anchor      = ch.CreateClientAnchor();
            anchor.Col1 = (/*setter*/ 2);
            anchor.Col2 = (/*setter*/ 5);
            anchor.Row1 = (/*setter*/ 10);
            anchor.Row2 = (/*setter*/ 16);
            patriarch.CreatePicture(anchor, indexPng);

            anchor      = ch.CreateClientAnchor();
            anchor.Col1 = (/*setter*/ 6);
            anchor.Col2 = (/*setter*/ 9);
            anchor.Row1 = (/*setter*/ 1);
            anchor.Row2 = (/*setter*/ 6);
            patriarch.CreatePicture(anchor, indexWmf);


            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb as HSSFWorkbook);
            byte[] pictureDataOut = (wb.GetAllPictures()[0] as HSSFPictureData).Data;
            Assert.IsTrue(Arrays.Equals(pictureDataEmf, pictureDataOut));

            byte[] wmfNoHeader = new byte[pictureDataWmf.Length - 22];
            Array.Copy(pictureDataWmf, 22, wmfNoHeader, 0, pictureDataWmf.Length - 22);
            pictureDataOut = (wb.GetAllPictures()[2] as HSSFPictureData).Data;
            Assert.IsTrue(Arrays.Equals(wmfNoHeader, pictureDataOut));
        }
コード例 #4
0
        static TestVBAMacroReader()
        {
            Dictionary <POIDataSamples, String> _expectedMacroContents = new Dictionary <POIDataSamples, String>();

            POIDataSamples[] dataSamples =
            {
                POIDataSamples.GetSpreadSheetInstance(),
                POIDataSamples.GetSlideShowInstance(),
                POIDataSamples.GetDocumentInstance(),
                POIDataSamples.GetDiagramInstance()
            };
            foreach (POIDataSamples sample in dataSamples)
            {
                _expectedMacroContents.Add(sample, ReadVBA(sample));
            }
            expectedMacroContents = _expectedMacroContents;
        }
コード例 #5
0
ファイル: TestOLE2Embeding.cs プロジェクト: hiodava/Romero
        public void TestReallyEmbedSomething()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            ISheet        sheet     = wb.CreateSheet();
            HSSFPatriarch patriarch = sheet.CreateDrawingPatriarch() as HSSFPatriarch;

            byte[]          pictureData = HSSFTestDataSamples.GetTestDataFileContent("logoKarmokar4.png");
            byte[]          picturePPT  = POIDataSamples.GetSlideShowInstance().ReadFile("clock.jpg");
            int             imgIdx      = wb.AddPicture(pictureData, PictureType.PNG);
            POIFSFileSystem pptPoifs    = GetSamplePPT();
            int             pptIdx      = wb.AddOlePackage(pptPoifs, "Sample-PPT", "sample.ppt", "sample.ppt");
            POIFSFileSystem xlsPoifs    = GetSampleXLS();
            int             imgPPT      = wb.AddPicture(picturePPT, PictureType.JPEG);
            int             xlsIdx      = wb.AddOlePackage(xlsPoifs, "Sample-XLS", "sample.xls", "sample.xls");
            int             txtIdx      = wb.AddOlePackage(GetSampleTXT(), "Sample-TXT", "sample.txt", "sample.txt");

            int rowoffset = 5;
            int coloffset = 5;

            ICreationHelper  ch     = wb.GetCreationHelper();
            HSSFClientAnchor anchor = (HSSFClientAnchor)ch.CreateClientAnchor();

            anchor.SetAnchor((short)(2 + coloffset), 1 + rowoffset, 0, 0, (short)(3 + coloffset), 5 + rowoffset, 0, 0);
            anchor.AnchorType = (/*setter*/ AnchorType.DontMoveAndResize);

            patriarch.CreateObjectData(anchor, pptIdx, imgPPT);

            anchor = (HSSFClientAnchor)ch.CreateClientAnchor();
            anchor.SetAnchor((short)(5 + coloffset), 1 + rowoffset, 0, 0, (short)(6 + coloffset), 5 + rowoffset, 0, 0);
            anchor.AnchorType = (/*setter*/ AnchorType.DontMoveAndResize);

            patriarch.CreateObjectData(anchor, xlsIdx, imgIdx);

            anchor = (HSSFClientAnchor)ch.CreateClientAnchor();
            anchor.SetAnchor((short)(3 + coloffset), 10 + rowoffset, 0, 0, (short)(5 + coloffset), 11 + rowoffset, 0, 0);
            anchor.AnchorType = (/*setter*/ AnchorType.DontMoveAndResize);

            patriarch.CreateObjectData(anchor, txtIdx, imgIdx);

            anchor = (HSSFClientAnchor)ch.CreateClientAnchor();
            anchor.SetAnchor((short)(1 + coloffset), -2 + rowoffset, 0, 0, (short)(7 + coloffset), 14 + rowoffset, 0, 0);
            anchor.AnchorType = (/*setter*/ AnchorType.DontMoveAndResize);

            HSSFSimpleShape circle = patriarch.CreateSimpleShape(anchor);

            circle.ShapeType = (/*setter*/ HSSFSimpleShape.OBJECT_TYPE_OVAL);
            circle.IsNoFill  = (/*setter*/ true);

            if (false)
            {
                FileStream fos = new FileStream("embed.xls", FileMode.Create);
                wb.Write(fos);
                fos.Close();
            }

            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb as HSSFWorkbook);

            MemoryStream   bos   = new MemoryStream();
            HSSFObjectData od    = wb.GetAllEmbeddedObjects()[0];
            Ole10Native    ole10 = Ole10Native.CreateFromEmbeddedOleObject((DirectoryNode)od.GetDirectory());

            bos = new MemoryStream();
            pptPoifs.WriteFileSystem(bos);
            Assert.IsTrue(Arrays.Equals(ole10.DataBuffer, bos.ToArray()));

            od    = wb.GetAllEmbeddedObjects()[1];
            ole10 = Ole10Native.CreateFromEmbeddedOleObject((DirectoryNode)od.GetDirectory());
            bos   = new MemoryStream();
            xlsPoifs.WriteFileSystem(bos);
            Assert.IsTrue(Arrays.Equals(ole10.DataBuffer, bos.ToArray()));

            od    = wb.GetAllEmbeddedObjects()[2];
            ole10 = Ole10Native.CreateFromEmbeddedOleObject((DirectoryNode)od.GetDirectory());
            Assert.IsTrue(Arrays.Equals(ole10.DataBuffer, GetSampleTXT()));
        }
コード例 #6
0
 public void HSLFfromNPOIFS()
 {
     FromNPOIFS(POIDataSamples.GetSlideShowInstance(), "SimpleMacro.ppt");
 }
コード例 #7
0
 public void XSLFfromFile()
 {
     FromFile(POIDataSamples.GetSlideShowInstance(), "SimpleMacro.pptm");
 }