1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
library(readxl)
library(tibble)
library(xlsx)
base <- read_excel("./Classeur2.xlsx", sheet = 1)
f1 <- read_excel("./Classeur_A.xlsx", sheet = 1)
f2 <- read_excel("./Classeur_B.xlsx", sheet = 1)
f1 <- add_column(f1, RETOUR = NA, .before = "A")
f2 <- add_column(f2, RETOUR = NA, .before = "A")
write.xlsx2(as.data.frame(f1), "./Classeur2.xlsx", row.names = FALSE, append = TRUE, sheetName = "A")
write.xlsx2(as.data.frame(f2), "./Classeur2.xlsx", row.names = FALSE, append = TRUE, sheetName = "B")
sheetname <- "Feuil1"
file <- "./Classeur2.xlsx"
wb <- loadWorkbook(file)
sheets <- getSheets(wb)
sheet <- sheets[[sheetname]]
rows <- getRows(sheet, rowIndex = 2:(nrow(base) + 1))
cells <- getCells(rows, colIndex = 1:ncol(base))
print(cells)
addHyperlink(cells[[1]], "A!A1", linkType="DOCUMENT")
addHyperlink(cells[[2]], "B!A1", linkType="DOCUMENT")
saveWorkbook(wb, file)
sheetname <- "A"
file <- "./Classeur2.xlsx"
wb <- loadWorkbook(file)
sheets <- getSheets(wb)
sheet <- sheets[[sheetname]]
rows <- getRows(sheet, rowIndex = 1:(nrow(f1) + 1))
cells <- getCells(rows, colIndex = 1:ncol(f1))
addHyperlink(cells[[1]], "Feuil1!A1", linkType="DOCUMENT")
saveWorkbook(wb, file)
sheetname <- "B"
file <- "./Classeur2.xlsx"
wb <- loadWorkbook(file)
sheets <- getSheets(wb)
sheet <- sheets[[sheetname]]
rows <- getRows(sheet, rowIndex = 1:(nrow(f2) + 1))
cells <- getCells(rows, colIndex = 1:ncol(f2))
addHyperlink(cells[[1]], "Feuil1!A1", linkType="DOCUMENT")
saveWorkbook(wb, file) |
Partager