Excel鼠标hover文本与xlsx包

有没有办法编程一个鼠标hover文本,就像这样: “看看7:35分”

我在R中使用xlsx包

它不必看起来像在video中的任何幻想。 我只想要一些文字出现在我hover在“???” 细胞。

有什么build议么?

为了让你们开始:

library(xlsx) write.xlsx("???",file="hoverText.xlsx",row.names = F,col.names = F) wb <- loadWorkbook("hoverText.xlsx") sheet <- getSheets(wb) 

编辑:

增加了一个评论(类似hover文本),但评论框是小的方式,我想写的文本。 (在Excel中,我可以手动更改大小,让我们尝试find一个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") 

EDIT2:

在searchnetworking之后,仍然没有成功。 这与这些function有关:

 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解决scheme的评论框自动resize

 CELL.Comment.Shape.TextFrame.AutoSize = True 

不知道如何在R的excel中运行VBA代码

  1. 从第一编辑代码:
  2. 将createCellComment更改为createCellComment2或覆盖该函数
  3. 这主要是xlsx :: createCellComment与评论框的heightwidth
 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) }