复制到剪贴板限制 [英] Copy to clipboard limitation

查看:188
本文介绍了复制到剪贴板限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于此主题的许多其他问题,我仍然找不到能避免我遇到问题的东西.

As many other question about this topic, I still didn't find something that could avoid my issue.

我想及时了解剪贴板在复制粘贴处理方面的局限性,并针对特定用途和程序ID限制其复制粘贴功能.

I'd like to know what are the limitations of the clipboard in term of copy paste processing in time and restrict its copy paste functionality for specific usage and program ID.

因为,我一直在为我的公司开发一个软件,该软件在Word/Excel和PowerPoint中采用模板,通过每天替换图片并粘贴模板中的新图形和图片来制作自动生成的报告.

Because, I've been developping a software for my company that takes a template in Word/Excel and PowerPoint to make auto generated reports by replacing the picture every day and pasting the new graph and the picture which are in the template.

但是,恐怕,因为复制到剪贴板似乎存在一些局限性

But, I'm afraid, because it seems to exist some limitations about the copy to clipboard

CopyBitmapToClipboard

ActiveWindow.View.PasteSpecial()

当我将表格/图像复制到剪贴板中并将其粘贴到Word/Excel/PowerPoint中时,这很好,但是如果我现在同时生成10个并行报告并使用复制粘贴机制,它将将会发生,它将其复制到另一个报告当前正在使用的Word/Excel/PowerPoint中.

When I copy a table/image into my clipboard and paste it in Word/Excel/PowerPoint it is fine, but if I have now 10 parallel reports which are generated at the same time and use the mechanism of copy paste, it will happen that it will copy it in the Word/Excel/PowerPoint that is currently being used by another report.

考虑到这一点,我有1个文档,并且将一张巨大的表格复制到剪贴板的剪贴板中,这将花费1秒的最佳时间(不是),这意味着在1天之内,我可以最多产生

Taking in consideration, I have 1 document, and the copy to clipboard of a table that is huge into powerpoint, would take the best case 1 second( which doesn't ), this would mean that in 1 day, I can generate a maximum of

1 copy paste procedure = 1 second

1minute = 60 second means 60 copy paste

1hour = 60min x 60 copy paste

1day = 24hours x 3600 copy paste

意味着我总共有 86400 个复制粘贴/报告.这是不可能的.一个文档将永远不会花费至少1秒的时间完成(对于大约20页的报告,带有30张幻灯片的powerpoint,带有6sheets的excel工作表).如何避免将复制到剪贴板中的内容粘贴到错误的文档中,因为两个文档都使用粘贴功能.

Means I have a total of 86400 copy paste/reports. Which is impossible. A document will never take minimum of 1 second to be complete( for reports which are about 20 pages, powerpoint with 30 slides, excel worksheet with 6sheets ). How to avoid that the content copied into clipboard will be pasted in the wrong document, since both documents use the paste fonction.

所以,我想知道,是否有可能在剪贴板中提供参考,告诉他,仅复制他word/excel/powerpoint中的内容,而不复制我刚才通过CTRL复制的内容+ C并在错误的文档中执行CTRL + V?

So, I'd like to know, if it is possible to give a reference into my clipboard, to tell him, to copy only the content inside his word/excel/powerpoint and not to copy what I just copied doing CTRL+C and to do CTRL+V in the wrong document?

目前,我们每天大约要生成50个报告(考虑到几个月前我们有2个报告要生成),这些报告的间隔时间为5分钟,但是当我们拥有86400个报告的那一天会发生什么每日报告生成?复制粘贴功能将破坏所有报告,并粘贴到错误的报告中.我可能不会在那里提供帮助,但是我想防止这种影响.

At the moment, we have about 50 reports daily to generate( taking in consideration that few months ago we had 2 reports to generate ), which are scheduled in interval of 5 minutes, but what will happen the day we will have 86400 daily reports to generate? The copy paste fonction will screw up all reports and paste in the wrong report. I might not be there to assist it, but I'd like to prevent that impact.

我正在C#/.NET中编写软件,但是由于正在运行 .bat ,因此我无法在其中编写程序以捕获当前正在生成的日程表/报告.用我编写的程序创建报告.

I was writing my software in C#/.NET, but I can't write inside it to catch if a current schedule/report is being generated, because I run a .bat that does the creation of the report with the program I wrote.

** 我的 .bat 的内容是: myprogram.exe/objectsourceprogram ="/sourcefile ="my template.doc/xls/ppt"/destinationfile ="my destination.doc/xls/ppt"

**Edited: Content of my .bat is: myprogram.exe /objectsourceprogram="" /sourcefile="my template.doc/xls/ppt" /destinationfile="my destination.doc/xls/ppt"

我只计划我的批处理文件,唯一可以做的是,等待一个计划完成,然后再开始下一个计划,但这会产生间隔

I'm only scheduling my batch file, the only thing that can be done is, waiting that one scheduling is being completed before starting the next one, but this will create intervales

推荐答案

我也处理过Word和Excel中自动生成的报告.您这样做的速度很慢,难怪它会很慢-.NET COM互操作非常慢,然后您的进程使用了​​其他线程,因此由于Office是单线程的,因此现在您必须在线程之间进行编组和同步.

I've dealt with auto-generated reports in Word and Excel as well. You're doing it the slow way, no wonder it's slow - .NET COM interop is quite slow as it its and then your process utilizes other threads, so now you have to take marshalling and synchronizing between threads since Office is single-threaded.

复制/粘贴是一种高级的用户功能,您可以将其用作hack,但是将其作为执行任务的主要方式是一个糟糕的选择.

Copy/paste is a high-level, user function and you can use it as a hack but relying on it as a primary way of executing your task is a poor choice.

更好的选择:Office API(VSTO,有人吗?)-我很确定您提出的报告中的任何内容都可以通过API复制.当心-太多的API调用会导致您的函数运行缓慢.

Better choice: Office APIs (VSTO, anyone?) - I'm pretty sure whatever you've come up with in terms of reports is reproducible through APIs. Beware - too many API calls and your functions can work slower.

最佳选择:OpenXML SDK.由于您仍在使用复制/粘贴",因此此处的学习曲线可能会很陡峭,但值得一提的是,您的文档处理时间将减少几个数量级.

Best choice: OpenXML SDK. The learning curve here will likely be steep since you're still using Copy/Paste but the payoff is that your document processing time will be reduced a couple orders of magnitude.

这篇关于复制到剪贴板限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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