-5

I need help in R.

I have data of 3 departments sales, marketing, accounts data. When exporting these data into excel, my desired output looks like of in the first sheet I need 3 rows of data i.e.: sales, marketing, accounts.

These 3 rows contains hyperlinks to the next sheets When I click into sales it will takes me into the sales sheet as well as remaining.

Can any one help how this can be done? Any help would be greatly appreciated.

Vincent Bonhomme
  • 6,837
  • 2
  • 23
  • 35
  • How is your question related to R? Can you please show us what you have tried so far in R to create the Excel file(s)? – R Yoda Apr 16 '16 at 11:46
  • Welcome to StackOverflow. Please read [how do I ask a good question](http://stackoverflow.com/help/how-to-ask) and [proding a minimal reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610) and edit your post accordingly. I.e., provide input data, the expected output + what you tried and in what way it failed. – lukeA Apr 16 '16 at 11:58
  • I exported multiple datasets (sales, marketing, account) into one excel files with different sheets, and also created hyperlink in excel but here what happens only web page hyperlinks is created but trying to assign hyperlinks to these 3 sheets within a file – Ravikumar Shalivahana Apr 16 '16 at 12:31
  • Can i expect answer from any one – Ravikumar Shalivahana Apr 20 '16 at 06:07
  • Please help me in this task – Ravikumar Shalivahana Apr 25 '16 at 04:39
  • I used this code to give hyperlinks to the next sheet library(xlsx) wb – Ravikumar Shalivahana May 16 '16 at 05:34

1 Answers1

1

To link to another sheet, use

addHyperlink(cell, "sheetname!colRow", linkType="DOCUMENT") 

For example

library(xlsx) 
wb <- createWorkbook() 
sheet1 <- createSheet(wb, "Sheet1") 
sheet2 <- createSheet(wb, "Sheet2") 
rows <- createRow(sheet1, 1:10) # 10 rows 
cells <- createCell(rows, colIndex=1:8) # 8 columns 

row <- 1
link <- paste0(names(getSheets(wb))[2], "!", "A", row)
setCellValue(cells[[row,1]], "link to other sheet") 
addHyperlink(cells[[row,1]], link, linkType="DOCUMENT") 

saveWorkbook(wb, "links.xlsx") 
shell.exec("links.xlsx")
lukeA
  • 50,755
  • 5
  • 83
  • 91