更新时间:2023-02-19 20:26:56
经过多次试验和错误...
函数 Range.InsertFile实际上并未插入文件,它将读取文本并将其追加到范围中。
After a lot of trial and error... The function "Range.InsertFile" doesn't actually inserts a file, it reads and appends the text into the Range.
解决方案很简单-复制粘贴...
The solution was simple - Copy paste...
using System.Collections.Specialized;
...
...
//Copy the Filename to Clipboard (setFile function uses StringCollection)
StringCollection collection = new StringCollection();
collection.Add(Environment.CurrentDirectory + "\\MyFile.zip");
Clipboard.SetFileDropList(collection);
//Paste into the selected Range.
range.Paste();
*还有 PasteSpecial功能不起作用(仅支持特定数据类型)
*There is also function "PasteSpecial" which didn't work (Only specific data types are supported).