From a WordprocessingDocument how do I check if the word document is empty?
从WordprocessingDocument如何检查word文档是否为空?
1 个解决方案
#1
According to the sample documentation here:
根据此处的示例文档:
http://msdn.microsoft.com/en-us/library/office/bb521237(v=office.14).aspx
you can fetch the ExtendedFilePropertiesPart
from the WordprocessingDocument
, fetch the "Characters" property with GetElementsByTagName("Characters")
, and if the value is zero that may be a good indicator that the document is empty, regardless of any other formatting that is present.
您可以从WordprocessingDocument获取ExtendedFilePropertiesPart,使用GetElementsByTagName(“Characters”)获取“Characters”属性,如果值为零,则可能是文档为空的良好指示,无论是否存在任何其他格式。
See the link above and scroll to the bottom of the page for the full source code.
请参阅上面的链接并滚动到页面底部以获取完整的源代码。
#1
According to the sample documentation here:
根据此处的示例文档:
http://msdn.microsoft.com/en-us/library/office/bb521237(v=office.14).aspx
you can fetch the ExtendedFilePropertiesPart
from the WordprocessingDocument
, fetch the "Characters" property with GetElementsByTagName("Characters")
, and if the value is zero that may be a good indicator that the document is empty, regardless of any other formatting that is present.
您可以从WordprocessingDocument获取ExtendedFilePropertiesPart,使用GetElementsByTagName(“Characters”)获取“Characters”属性,如果值为零,则可能是文档为空的良好指示,无论是否存在任何其他格式。
See the link above and scroll to the bottom of the page for the full source code.
请参阅上面的链接并滚动到页面底部以获取完整的源代码。