I have recently started DOTNET development for office. I am a little persistent about full encapsulation, because I can useCodeControl the performance in Word and Excel. If you use a host instance or an office script, it is not so casual.
When processing Excel, we found that the Office InterOP class provided by Microsoft was not very well-encapsulated and decided to encapsulate it by ourselves.
Encapsulation options:
1. encapsulate the main Excel classes and provide certain helper functions externally. It also provides functions for directly accessing classes under Microsoft. Office. InterOP. Excel.
Disadvantage: the customer's code must reference this office library. The customer needs to understand the Microsoft. Office. InterOP. excel model. Even more miserable, you need to know a lot of Enum that cannot be automatically prompted.
Advantage: The amount of encapsulated code is small, and the release of resources is completed by the customer code (you cannot predict when the customer does not need to use a resource. The best resource release mode is, no, release immediately)
2. Full encapsulation: All Excel classes
Disadvantage: the code is too large to release resources (resources are always allocated and code tracing is required), and the function design is troublesome (no one knows the customer's code requirements)
Advantage: the customer code is much simpler.
Despite the trouble, I chose 2 for full encapsulation.
The Code has not been completed. Haha/files/jeasonzhao/jeasonzhao.office.rar