有没有办法对鼠标悬停文本进行编程,如下所示:"look at 7:35 min"
我在R。
中使用xlsx包它不必看起来像视频中的任何幻想。当我将鼠标悬停在“???”上时,我只想要显示一些文字细胞
有什么建议吗?
让你们开始:
library(xlsx)
write.xlsx("???",file="hoverText.xlsx",row.names = F,col.names = F)
wb <- loadWorkbook("hoverText.xlsx")
sheet <- getSheets(wb)
添加注释(类似于悬停文本),但是对于我打算写的文本,注释框是小的。 (在Excel中我可以手动更改大小,让我们尝试找到一种R方式来更改注释框大小)
library(xlsx)
write.xlsx("???",file="hoverText.xlsx",row.names = F,col.names = F)
wb <- loadWorkbook("hoverText.xlsx")
sheet <- getSheets(wb)[[1]]
row <- xlsx::getRows(sheet)
cell <- xlsx::getCells(row, colIndex = 1)
comment <- "most foobar comment of all time\nhopefully with newline"
createCellComment(cell[[1]], string=comment, author=NULL, visible=TRUE)
saveWorkbook(wb,file="hoverText.xlsx")
ClientAnchor anchor = factory.createClientAnchor();
anchor.setCol1(cell.getColumnIndex()); anchor.setCol2(cell.getColumnIndex() + 1);
anchor.setRow1(cell.getRowIndex()); anchor.setRow2(cell.getRowIndex()+ 1);
anchor.setDx1(100);
anchor.setDx2(100);
anchor.setDy1(100);
anchor.setDy2(100);
评论框自动调整大小有一个vba解决方案
CELL.Comment.Shape.TextFrame.AutoSize = True
还不知道如何从R
在excel中运行VBA代码答案 0 :(得分:0)
height
和width
的xlsx :: createCellComment createCellComment2 <- function (cell, string, author = NULL, visible = TRUE,height=2,width=2) { sheet <- .jcall(cell, "Lorg/apache/poi/ss/usermodel/Sheet;", "getSheet") wb <- .jcall(sheet, "Lorg/apache/poi/ss/usermodel/Workbook;", "getWorkbook") factory <- .jcall(wb, "Lorg/apache/poi/ss/usermodel/CreationHelper;", "getCreationHelper") anchor <- .jcall(factory, "Lorg/apache/poi/ss/usermodel/ClientAnchor;", "createClientAnchor") .jcall(anchor, "V", "setCol2", as.integer(width)) .jcall(anchor, "V", "setRow2", as.integer(height)) drawing <- .jcall(sheet, "Lorg/apache/poi/ss/usermodel/Drawing;", "createDrawingPatriarch") comment <- .jcall(drawing, "Lorg/apache/poi/ss/usermodel/Comment;", "createCellComment", anchor) rtstring <- factory$createRichTextString(string) comment$setString(rtstring) if (!is.null(author)) .jcall(comment, "V", "setAuthor", author) if (visible) .jcall(cell, "V", "setCellComment", comment) invisible(comment) }