Пример #1
0
        public override string ReadContents()
        {
            /*
             * The content from all PowerPoint slides are stored in their own XML file (one file for
             * each slide).  Likewise, the contents of each note for a slide is stored in it's own
             * XML file.
             * Theses files can be found in the directories \\ppt\slides and \\ppt\\notesslides
             */

            using (OdfUnpacker packer = new OdfUnpacker())
            {
                string newFolder = packer.UnpackOdf(_FilePath);

                List <string> fileArray = new List <string>();
                if (Pri.LongPath.Directory.Exists(newFolder + "\\ppt\\slides"))
                {
                    fileArray.AddRange(Pri.LongPath.Directory.GetFiles(newFolder + "\\ppt\\slides", "*.xml", SearchOption.AllDirectories).ToList());
                }

                if (Pri.LongPath.Directory.Exists(newFolder + "\\ppt\\notesslides"))
                {
                    fileArray.AddRange(Pri.LongPath.Directory.GetFiles(newFolder + "\\ppt\\notesslides", "*.xml", SearchOption.AllDirectories).ToList());
                }

                string xmlContent      = string.Empty;
                string documentContent = string.Empty;
                foreach (var file in fileArray)
                {
                    xmlContent = Pri.LongPath.File.ReadAllText(file);
                    XDocument xDoc = XDocument.Parse(xmlContent);
                    documentContent += xDoc.Root.Value;
                }
                return(documentContent);
            }
        }
Пример #2
0
        public override string ReadContents()
        {
            /*
             * Excel files are slightly more complex than Word
             * files for parsing.  For efficiency they store
             * strings in a shared XML file regardless of
             * worksheet location.  This is easy to retrieve and is
             * treated the same as for Word.  But formulas and non
             * text based values are stored in individual XML files
             * for each worksheet, in the xl\worksheets folder.
             */

            //TODO: in line with comment above, make this support
            //more than the shared string extraction.

            using (OdfUnpacker packer = new OdfUnpacker())
            {
                string newFolder         = packer.UnpackOdf(_FilePath);
                string sharedXmlLocation = newFolder + "\\xl\\sharedStrings.xml";
                string xmlContent        = File.ReadAllText(sharedXmlLocation);

                XDocument xDoc            = XDocument.Parse(xmlContent);
                string    documentContent = xDoc.Root.Value;
                return(documentContent);
            }
        }
Пример #3
0
        public override string ReadContents()
        {
            using (OdfUnpacker packer = new OdfUnpacker())
            {
                string newFolder       = packer.UnpackOdf(_FilePath);
                string xmlFileLocation = newFolder + "\\word\\document.xml";
                string xmlContent      = File.ReadAllText(xmlFileLocation);

                XDocument xDoc            = XDocument.Parse(xmlContent);
                string    documentContent = xDoc.Root.Value;
                return(documentContent);
            }
        }