2017-03-27 4 views
1

Gibt es eine Möglichkeit, einen Maus Hover-Text zu programmieren, so etwas wie diese: "look at 7:35 min"Excel Maus Hover-Text mit xlsx Paket

Im das xlsx Paket in R. mit

Es hat Lust etwas aussehen mag nicht in dem Video. Ich möchte nur, dass ein Text erscheint, wenn ich den "???" Zelle.

Irgendwelche Vorschläge?

Um euch den Einstieg:

library(xlsx) 

write.xlsx("???",file="hoverText.xlsx",row.names = F,col.names = F) 

wb <- loadWorkbook("hoverText.xlsx") 
sheet <- getSheets(wb) 

EDIT:

Kommentar (so etwas wie ein Hover-Text) fügt hinzu, aber die Kommentar-Box ist viel zu klein, für die Text i Absicht schreiben. (In Excel kann ich manuell die Größe ändern, kann versuchen, eine R Weg zu finden, das Kommentarfeld Größe zu ändern)

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: Suchen im Internet immer noch keinen Erfolg

nach Stunden. Es hat etwas mit diesen Funktionen zu tun:

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); 

Es gibt eine vba Lösung für die Auto-Kommentar-Box

CELL.Comment.Shape.TextFrame.AutoSize = True 

nicht Sizing weiß doch, wie

Antwort

0
    VBA-Code in Excel von R laufen
  1. Nehmen Sie den Code aus 1. Edit:
  2. Ändern Sie createCellComment zu createCellComment2 oder überschreiben Sie die Funktion
  3. Diese
  4. ist meist die xlsx :: createCellComment mit height und width der Kommentarfeld
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) 
} 
Verwandte Themen