开发者

Excel inter-op file renaming

I have a program that is using the excel interop routines to generate a bunch of reports based on an excel template.开发者_如何学JAVA

This all works acceptably, but the side effect that I am trying to figure out is how to prevent the users from overwriting the original template.

It has to be excel for reasons out of my control, which as far as I can tell means that the template has to be on the intranet somewhere that all the users can read / write. (If it's an archive, then the application run by the users won't be able to fill it with new data)

I was thinking of trying to address this by renaming the file and moving it somewhere else on the network, but I'm not sure if this is even possible. (Thus the name of the thread)

Also, there might be an even better way of addressing the problem that I just haven't thought of.


I haven't tried, but I think that if you put it in a read-only share, you should still be able to open it and write things to the open document, just that it can't save it back to that location, instead you'll have to use SaveAs to save it somewhere else.

Otherwise, if I'm wrong about that, then do as you said yourself in that you put it in a read-only share and then copy it somewhere else before you start doing the interop. Just use File.Copy to copy it, maybe to the name returned Path.GetTempFileName to make sure you don't overwrite anything else, and then in the end, just use SaveAs to save it wherever the user wants.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜