public void ShowContentsFunc(IOfficeFile file)
 {
     if (file is IWordFile)
     {
         wordFile = file as IWordFile;
     }
     else if (file is IPowerPointFile)
     {
         IPowerPointFile pptFile = file as IPowerPointFile;
     }
 }
Exemplo n.º 2
0
 private void ShowContent(IOfficeFile file)
 {
     if (file is IWordFile)
     {
         IWordFile wordFile = file as IWordFile;
         this.tbInformation.Text = wordFile.ParagraphText;
     }
     else if (file is IPowerPointFile)
     {
         IPowerPointFile pptFile = file as IPowerPointFile;
         this.tbInformation.Text = pptFile.AllText;
     }
     else
     {
         this.tbInformation.Text = String.Format("Cannot extract content from this file.");
     }
 }
        /// <summary>
        /// 展示文件内容
        /// </summary>
        /// <param name="file">文件路径</param>
        /// <returns>文件内容</returns>
        private string ShowContent(IOfficeFile file)
        {
            string ans2 = "";

            if (file is IWordFile)
            {
                IWordFile wordFile = file as IWordFile;
                ans2 = wordFile.ParagraphText;
            }
            else if (file is IPowerPointFile)
            {
                IPowerPointFile pptFile = file as IPowerPointFile;
                ans2 = pptFile.AllText;
            }
            else
            {
                ans2 = string.Format("无法在此文件中提取数据.");
            }
            return(ans2);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 获取office文档内容
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 private static string _GetContent(IOfficeFile file)
 {
     if (file is IWordFile)
     {
         IWordFile wordFile = file as IWordFile;
         return(wordFile.ParagraphText);
     }
     else if (file is IPowerPointFile)
     {
         IPowerPointFile pptFile = file as IPowerPointFile;
         return(pptFile.AllText);
     }
     else if (file is ITextFile)
     {
         ITextFile textFile = file as ITextFile;
         return(textFile.CommentText);
     }
     else if (file is IPDFFile)
     {
         IPDFFile pdfFile = file as IPDFFile;
         return(pdfFile.CommentText);
     }
     else if (file is IHtmlFile)
     {
         IHtmlFile htmlFile = file as IHtmlFile;
         return(htmlFile.CommentText);
     }
     else if (file is IExcelFile)
     {
         IExcelFile excelFile = file as IExcelFile;
         return(excelFile.CommentText);
     }
     else
     {
         return(String.Format("无法解析"));
     }
 }