如何检查 Word 页眉中的空间量?

huangapple go评论63阅读模式
英文:

How can I check the amount of space in a Word header?

问题

我目前正在进行一个使用Office应用程序的桌面自动化项目。在测试过程中,我需要检查头部内容是否正确。其中一个关键因素是头部的位置。有没有办法检查头部内的空间,甚至是页面上的坐标?类似这样的内容。

我已经查阅了Office Open XML文档,但未找到与间距/位置有关的内容。有什么想法吗?

英文:

I'm currently working on a desktop automation project using the Office applications. I need to check that the header content is correct during the test. A key factor that needs to be right is the position of the header. Is there a way of checking the space within the header, or even the co-ordinates on the page? Something along those lines.

I've looked at the Office Open XML docs but couldn't see anything to do with spacing/position. Any ideas?

答案1

得分: 1

如何在Java中执行这个操作:
首先,您需要使用Java读取XML头部内容,并将其赋值给变量。

<header>  headerNameWithSpaces </header>

String headerValue = "  headerNameWithSpaces";

然后,使用Java 8的特性来计算空格数量。

long spaceCount = headerValue.chars().filter(Character::isWhitespace).count();
英文:

How to do it using java:
First you need to read xml header content via java and assign it into variable.

<header>  headerNameWithSpaces </header>

String headerValue = "  headerNameWithSpaces";

then use java 8 features to count the spaces.

long spaceCount = headerValue.chars().filter(Character::isWhitespace).count();

huangapple
  • 本文由 发表于 2020年4月6日 18:24:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/61057648.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定