如何使用Interop从C#中的Excel或PowerPoint文件获取修订? [英] How to get revisions from Excel or PowerPoint Files in C# using Interop?

查看:116
本文介绍了如何使用Interop从C#中的Excel或PowerPoint文件获取修订?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在开发一个需要计算文档和修订中的单词数的应用程序.

Am working on an application that needs to count words from documents and revisions.

您可以在此处中看到,我已经为Word文档解决了这个问题(可以解决的很多),但是现在我发现自己想知道如何从Excel或PowerPoint文档中获取数据.

as you can see here, I have already resolved this for Word Documents (well, as much it can be resolved) but now i find myself wondering how to get that data from Excel or PowerPoint documents.

到目前为止,MSDN文档没有帮助-我会一直寻找,但是如果有人知道答案,我将不胜感激.

The MSDN Documentation didn't help so far - i will keep looking but if anyone knows the answer i would appreciate a little help.

编辑:因此,利用@Andrew提供的信息(谢谢他),我得到了Excel部分的以下代码:

So taking the information provided by @Andrew (Thanks go to him) i got this code for the Excel part:

foreach (Excel._Worksheet s in ExcelBook.Sheets)
        {
            if (s.UsedRange.Value2 != null)
            {
                for (int i = 1; i <= s.UsedRange.Value2.GetLength(0); i++)
                {
                    for (int j = 1; j <= s.UsedRange.Value2.GetLength(1); j++)
                    {
                        string content = s.UsedRange.Value2[i, j];
                        MessageBox.Show(i + " - " + j + " - " + content);
                    }
                }
            }
        }

现在,我可以用它来对工作表中所有单元格中的单词进行计数,但是这仍然对修订无济于事-任何人都知道如何跟进此事?

Now i can use that to count words in all cells in the Sheet, however that still doesn't help with revisions - anyone has an idea on how to follow up on this?

推荐答案

从与该Word的OM链接的代码示例中可以看出,它使您可以使用其修订跟踪功能.方便.

It appears from the code example that you linked to that Word's OM gives you access to its revision tracking feature. Handy.

PowerPoint没有任何修订跟踪版本,因此除非您像Andrew所建议的那样,否则您什么都不需要处理,除非您一次从演示文稿中提取并存储文本,然后再进行相同操作并比较两者.无论如何,获取文本并不是很困难.比较两组文本以查找修订可能会非常复杂.

PowerPoint has no revision tracking whatever, so there's nothing for you to work with unless as Andrew has suggested, you extract and store the text from a presentation at one point, then later do the same and compare the two. Getting at the text, most of it anyhow, isn't all that difficult. Comparing two sets of text looking for revisions could be quite complex.

这里有一些VBA宏可用于提取幻灯片上的常规文本(免责声明:我的网站): http://www.pptfaq.com/FAQ00274.htm

There are some VBA macros for extracting regular text on slides here (disclaimer: my site): http://www.pptfaq.com/FAQ00274.htm

这些方法思想简单,不会处理分组形状,表格,图表等中的文本,但是它们可以帮助您入门.

These are simple-minded and won't deal with text in grouped shapes, tables, charts and so on, but they'll get you started.

这篇关于如何使用Interop从C#中的Excel或PowerPoint文件获取修订?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆