这是我修改 PowerPoint 演示文稿、将其另存为新文件、关闭它,然后尝试打开该文件的代码。
var doc = PresentationDocument.Open(@"d:\temp.pptx", true);
//... proccess presentation
doc.SaveAs(@"d:\temp2.pptx");
doc.Close();
var doc2 = PresentationDocument.Open(@"d:\temp2.pptx", false);
doc2.Close();
Run Code Online (Sandbox Code Playgroud)
我不明白为什么运行时会抛出异常:
该进程无法访问文件“x”,因为它正被另一个进程使用。
我在 PowerPoint 中创建了一个表格,我想将每个单元格中的文本水平居中。我使用了MsoHorizontalAnchor.msoAnchorCenter。
如果文本很短且在一行中,则效果很好,但如果文本很长,则显示在 1 行以上且不居中。编码:
myShape.Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = "shortOK";
myShape.Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = "Long text is not displayed centered";
myShape.Table.Cell(1, 1).Shape.TextFrame.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorMiddle;
myShape.Table.Cell(1, 2).Shape.TextFrame.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorMiddle;
myShape.Table.Cell(1, 1).Shape.TextFrame.HorizontalAnchor = Microsoft.Office.Core.MsoHorizontalAnchor.msoAnchorCenter;
myShape.Table.Cell(1, 2).Shape.TextFrame.HorizontalAnchor = Microsoft.Office.Core.MsoHorizontalAnchor.msoAnchorCenter;
Run Code Online (Sandbox Code Playgroud)
如果显示在 1 法以内,您知道如何使文本居中吗?
我正在开发一个 Angular Web 服务,用于创建照片旅程并使用 Leaflet 将它们显示在地图上。当我上传图片时,我从 EXIF 数据中获取它们的坐标,并从中获取DateTimeOriginal,它返回如下字符串:
然后将它们保存在数组中,以便进一步连接地图上的路径。
我在按时间戳对该数组进行排序以便正确连接地图上的标记时遇到问题:
如何按时间戳排序?
我知道弹出窗口是由一个 html 文件组成的。下面是我的代码。出于某种原因,当我单击该图标时,弹出窗口不会打开。关于问题可能是什么的任何想法?
{
"name": "Popup Snake",
"version": "1.0",
"description": "A simple snake game popup, that can be opened by clicking the icon in the top right (after installing)",
"page_action": {
"default_popup": "popup.html"
},
"manifest_version": 2
}
Run Code Online (Sandbox Code Playgroud) 我有一个登录过程,在向服务器发送请求并获得响应后,我执行以下操作:
this.$auth.setToken(response.data.token);
this.$store.dispatch("setLoggedUser", {
username: this.form.username
});
Run Code Online (Sandbox Code Playgroud)
现在,我想在使用赛普拉斯进行测试时模拟这种行为,因此我不需要每次运行测试时都实际登录。
所以我创建了一个命令:
Cypress.Commands.add("login", () => {
cy
.request({
method: "POST",
url: "http://localhost:8081/api/v1/login",
body: {},
headers: {
Authorization: "Basic " + btoa("administrator:12345678")
}
})
.then(resp => {
window.localStorage.setItem("aq-username", "administrator");
});
});
Run Code Online (Sandbox Code Playgroud)
但是我不知道如何模仿“ setLoggedUser”操作,有什么想法吗?
我有一个将列重新排列为特定顺序的宏。
Sub ArrangeColumns()
' ArrangeColumns Macro
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Columns("K:K").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Columns("H:H").Select
Selection.Cut
Columns("G:G").Select
Selection.Insert Shift:=xlToRight
Columns("J:J").Select
Selection.Cut
Columns("H:H").Select
Selection.Insert Shift:=xlToRight
Columns("J:J").Select
Selection.Cut
Columns("I:I").Select
Selection.Insert Shift:=xlToRight
Columns("K:K").Select
Selection.Cut
Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Range("P11").Select
End Sub
Run Code Online (Sandbox Code Playgroud)
这不再有效,因为无法再保证原始数据的列按特定顺序排列。
有没有办法重写上面的代码(是的,它是由“记录宏”创建的)以"Columns("C:C")", Columns("A:A")"用它们的列标题名称替换行等?
更好的是有没有更好的方法来解决这个问题?
我想将 JavaScript API 中的合并字段 ( <<xyz>>) 插入到单词表中。但是,我无法找到 Office Word 加载项的 JavaScript API。
---
output:
word_document: default
---
```{r setup, include=FALSE}
data("mtcars")
library(tidyverse)
library(xtable)
library(sjPlot)
library(kableExtra)
```
```{r, results='asis'}
df <- mtcars %>%
group_by(cyl) %>%
summarise(disp = mean(disp),
wt = mean(wt),
n = n()
)
kable(df)
# tab_df(df)
# xtable(df)
```
Run Code Online (Sandbox Code Playgroud)
我已经尝试过xtable、tab_df、 和kable生成带有表格的Word文档。当“编织到 HTML 文档”时,所有表格看起来都很好。当“knit to Word”时,xtable 不显示表格tab_df,而是kable生成一个只有一列的表格:
kable(df)
cyl
disp
wt
n
4
105.1364
2.285727
Run Code Online (Sandbox Code Playgroud) 想要在打字稿中使用officejs显示/隐藏自定义功能区按钮。
尝试使用 jquery 获取自定义功能区按钮的元素,但无法获得相同的元素,因为每次 excel 运行时 id 都会变得随机。
$("#id__1157").id.hide()
预期结果:想要使用 typescript 中的 Officejs 在 Excel 中显示/隐藏自定义功能区按钮
我的表格如下所示: Word POI 表
正如您所看到的,文本与单元格的顶部对齐。我想让它垂直居中或与单元格底部对齐。我试图实现它,cell.setVerticalAlignment(XWPFVertAlign.CENTER);但它不会改变任何东西。我可以通过 table.setCellMargin() 为单元格添加边距。它在单元格顶部添加了边距,但文本下方的空白区域使单元格太大。也许有办法让单元格宽度适合文本高度?我的预期结果如下所示:
预期结果
这是我的代码的一部分:`
XWPFTable table = document.createTable();
CTTblWidth tableIndentation = table.getCTTbl().getTblPr().addNewTblInd();
tableIndentation.setW(BigInteger.valueOf(720));
tableIndentation.setType(STTblWidth.DXA);
XWPFTableRow tableRowOne = table.getRow(0);
XWPFParagraph paragraphTable = tableRowOne.getCell(0).addParagraph();
table.setCellMargins(0, 50, 0, 0);
XWPFRun runT = paragraphTable.createRun();
runT.setBold(true);
runT.setColor("ffffff");
runT.setText("REFERENCE ACTIVITIES PROVIDED: " + String.valueOf(def.format(c.getEarnedSum())) + " POINTS EARNED");
runT = tableRowOne.addNewTableCell().addParagraph().createRun();
runT = tableRowOne.addNewTableCell().addParagraph().createRun();
tableRowOne.getCell(0).getCTTc().addNewTcPr().addNewShd().setFill("8dc63f");
tableRowOne.getCell(1).getCTTc().addNewTcPr().addNewShd().setFill("8dc63f");
tableRowOne.getCell(2).getCTTc().addNewTcPr().addNewShd().setFill("8dc63f");
tableRowOne.getCell(0).removeParagraph(0);
tableRowOne.getCell(1).removeParagraph(0);
tableRowOne.getCell(2).removeParagraph(0);`
Run Code Online (Sandbox Code Playgroud) ms-word ×3
c# ×2
javascript ×2
office-js ×2
powerpoint ×2
angular ×1
apache-poi ×1
cypress ×1
excel ×1
html ×1
java ×1
json ×1
kable ×1
leaflet ×1
ms-office ×1
openxml ×1
openxml-sdk ×1
popup ×1
r ×1
r-markdown ×1
ribbonx ×1
sorting ×1
timestamp ×1
vba ×1
vue.js ×1
vuex ×1
word-addins ×1
word-field ×1