Office 365 API 在 Word 在线搜索替换(故障?)
Office 365 API Search replace on Word online (fault?)
我使用 Office api (JavaScript)
开发了一个插件
它在 Word 桌面客户端 (2016) 上运行良好,但使用 Word 365 在线版本 "search and replace" 我使用的代码使替换的字符串有时向左,有时向右,有时精确。
这很可能是 Word online 中的一个错误,但为了确定我在这里问你们是否有人知道为什么会发生这种情况。
这似乎是Word在替换之间使用了一个字符数,然后不顾一切地替换造成的。
这是一个简短的示例,搜索到的字符串是(大于和小于使用 £ 替换,因为我不能 post 以有意义的方式使用符号!)
£client name£!
在这种情况下,我使用“Super Client”进行替换,您可以看到替换未命中。 (这只是一段文字,有些地方还不错)
我们理解 £cSuper Client 这个项目的近期和长期目标,我们已经制定了这个计划来响应您的初始需求,并与 £cliSuper Clientr 在未来几年。
我 运行 替换的代码(在 api 中)是:
Word.run(function (ctx) {
var results = ctx.document.body.search("£client name£!");
ctx.load(results);
return ctx.sync()
.then(function () {
var replaceCount = results.items.length;
if (!replaceCount || replaceCount === 0) {
return;
}
for (var i = 0; i < replaceCount; i++) {
results.items[i].insertText(userClientName, Word.InsertLocation.replace);
results.items[i].font.color = "#005882";
} return ctx.sync()
.then (function () {// do something }
感谢您报告 Jerry,这实际上是一个错误(已知问题),正在修复中。将在修复生效时更新此问题。谢谢!
我使用 Office api (JavaScript)
开发了一个插件它在 Word 桌面客户端 (2016) 上运行良好,但使用 Word 365 在线版本 "search and replace" 我使用的代码使替换的字符串有时向左,有时向右,有时精确。 这很可能是 Word online 中的一个错误,但为了确定我在这里问你们是否有人知道为什么会发生这种情况。
这似乎是Word在替换之间使用了一个字符数,然后不顾一切地替换造成的。
这是一个简短的示例,搜索到的字符串是(大于和小于使用 £ 替换,因为我不能 post 以有意义的方式使用符号!)
£client name£!
在这种情况下,我使用“Super Client”进行替换,您可以看到替换未命中。 (这只是一段文字,有些地方还不错)
我们理解 £cSuper Client 这个项目的近期和长期目标,我们已经制定了这个计划来响应您的初始需求,并与 £cliSuper Clientr 在未来几年。
我 运行 替换的代码(在 api 中)是:
Word.run(function (ctx) {
var results = ctx.document.body.search("£client name£!");
ctx.load(results);
return ctx.sync()
.then(function () {
var replaceCount = results.items.length;
if (!replaceCount || replaceCount === 0) {
return;
}
for (var i = 0; i < replaceCount; i++) {
results.items[i].insertText(userClientName, Word.InsertLocation.replace);
results.items[i].font.color = "#005882";
} return ctx.sync()
.then (function () {// do something }
感谢您报告 Jerry,这实际上是一个错误(已知问题),正在修复中。将在修复生效时更新此问题。谢谢!