Вот простая утилита Shiny для открытия рабочих книг Excel и загрузки отдельного рабочего листа из выпадающего списка. Затем он отображает таблицу. Надеюсь, это поможет вам начать.
# Utility to read any Excel workbook and display a worksheet
library("shiny")
library("gdata")
library("tableHTML")
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Utility to read and display an Excel spreadsheet"),
sidebarLayout(
sidebarPanel (label="Data Source",
# Spreadsheet name and sheet name
fileInput("spreadsheetName", "Spreadsheet Name",accept = c(".xlsx")),
selectInput(inputId = "worksheet", label="Worksheet Name",choices=''),
actionButton(inputId = "getData",label="Get Data")),
mainPanel (
tableHTML_output("table1Data")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
# Read the data from the spreadsheet
observe({
# Get the annual data
# Check if file is there... if not, exit and wait for it again
inFile <- input$spreadsheetName
if (is.null(inFile)) {
return (NULL)
}
else {
# Set up the selection for the worksheet names within the selected file
filePath <<- inFile$datapath
selectionWorksheet <- sort(unique(sheetNames (inFile$datapath)))
updateSelectInput(session, "worksheet", choices = selectionWorksheet)
}
})
# Get data
observeEvent(input$getData, {
# Get the data from the spreadsheet worksheets
worksheetData <- read.xls (filePath, sheet=input$worksheet, header=TRUE, stringsAsFactors = FALSE)
# Print the Annual table
output$table1Data <- renderTable ({
worksheetData
# End of main program
})
})
}
# Run the application
shinyApp(ui = ui, server = server)