Office 剪贴板需要时间才能显示更改
我在 Excel 中遇到一个非常奇怪的问题。我已覆盖 CTRL+C 和 CTRL+V 键,并且在复制时,我将自定义 DataObject 放在包含 Excel 格式和自定义格式的剪贴板上。
我将数据复制到剪贴板,复制时没有任何问题。我还可以在 Office 剪贴板中看到它。现在,我从 Excel 外部(从记事本)复制一些文本,并尝试将其粘贴到 Excel 中,但 Excel 粘贴了我从 Excel 工作表复制的先前数据。我正在使用 Worksheet.Paste(...) 方法进行粘贴。
粘贴多次后,Excel开始粘贴新数据,但不固定。有时我根本看不到新数据,尽管 Windows 剪贴板查看器和 Office 剪贴板在我从记事本复制后都会立即显示新数据。
知道为什么 Office 需要时间来粘贴这些新数据吗?
I am facing a very weird problem in Excel. I have overridden the CTRL+C and CTRL+V keys and on copy, I put my custom DataObject on the clipboard that contains both the Excel formats and my custom formats.
I copy my data to the clipboard and it gets copied without any problem. I can also see it in the Office Clipboard. Now I copy some text from outside Excel (from Notepad) and try to paste it in Excel but Excel pastes the previous data that I copied from Excel sheet. I am pasting using Worksheet.Paste(...) method.
After pasting a number of times, Excel starts pasting the new data but it is not fixed. Sometimes I do not see the new data at all although the Windows Clipboard Viewer and Office Clipboard both show the new data as soon as I copy from notepad.
Any idea why Office takes time to paste this new data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Excel 宁愿从其自己的内部缓冲区粘贴而不是从剪贴板粘贴,因此只有在有理由相信剪贴板已更改时才会查看剪贴板。如果您干扰剪贴板通知链,它可能不知道更新。或者,它可能仅在失去/获得焦点时检查剪贴板更新。即,如果 Excel 仍然具有焦点,并且您的附加组件在后台将某些内容复制到剪贴板,则它没有理由认为它需要查看剪贴板。
Excel would rather paste from its own internal buffer than the clipboard, so it only looks at the clipboard if it has reason to believe that it has changed. If you are interfering with the clipboard notification chain, it may not know about the updates. Or it may only check for clipboard updates if it loses/gains focus. i.e. if Excel still has focus and your add-on copies something to the clipboard in the background, it has no reason to think that it needs to look at the clipboard.