0

是否有用于更新 Excel 电子表格中的单元格/范围的 R 包?我不想覆盖整个电子表格。只需针对单个单元格/范围。原因是电子表格中的其他单元格有公式,我不想碰。

类似于GemBox为 Visual Basic 提供的东西?

注意:我们需要一些不依赖于 JRE 的东西。

4

1 回答 1

1

我经常使用 package XLConnect,它提供了许多功能:

library("XLConnect")
ls("package:XLConnect")
#  [1] "addImage"                        "appendNamedRegion"              
#  [3] "appendWorksheet"                 "aref"                           
#  [5] "aref2idx"                        "clearNamedRegion"               
#  [7] "clearRange"                      "clearRangeFromReference"        
#  [9] "clearSheet"                      "cloneSheet"                     
# [11] "col2idx"                         "createCellStyle"                
# [13] "createFreezePane"                "createName"                     
# [15] "createSheet"                     "createSplitPane"                
# [17] "cref2idx"                        "existsName"                     
# [19] "existsSheet"                     "extractSheetName"               
# [21] "getActiveSheetIndex"             "getActiveSheetName"             
# [23] "getBoundingBox"                  "getCellFormula"                 
# [25] "getCellStyle"                    "getCellStyleForType"            
# [27] "getDefinedNames"                 "getForceFormulaRecalculation"   
# [29] "getLastColumn"                   "getLastRow"                     
# [31] "getReferenceCoordinates"         "getReferenceCoordinatesForName" 
# [33] "getReferenceCoordinatesForTable" "getReferenceFormula"            
# [35] "getSheetPos"                     "getSheets"                      
# [37] "getTables"                       "hideSheet"                      
# [39] "idx2aref"                        "idx2col"                        
# [41] "idx2cref"                        "isSheetHidden"                  
# [43] "isSheetVeryHidden"               "isSheetVisible"                 
# [45] "loadWorkbook"                    "mergeCells"                     
# [47] "mirai"                           "normalizeDataframe"             
# [49] "onErrorCell"                     "print"                          
# [51] "readNamedRegion"                 "readNamedRegionFromFile"        
# [53] "readTable"                       "readWorksheet"                  
# [55] "readWorksheetFromFile"           "removeName"                     
# [57] "removePane"                      "removeSheet"                    
# [59] "renameSheet"                     "saveWorkbook"                   
# [61] "setActiveSheet"                  "setAutoFilter"                  
# [63] "setBorder"                       "setCellFormula"                 
# [65] "setCellStyle"                    "setCellStyleForType"            
# [67] "setColumnWidth"                  "setDataFormat"                  
# [69] "setDataFormatForType"            "setFillBackgroundColor"         
# [71] "setFillForegroundColor"          "setFillPattern"                 
# [73] "setForceFormulaRecalculation"    "setHyperlink"                   
# [75] "setMissingValue"                 "setRowHeight"                   
# [77] "setSheetColor"                   "setSheetPos"                    
# [79] "setStyleAction"                  "setStyleNamePrefix"             
# [81] "setWrapText"                     "show"                           
# [83] "summary"                         "swissfranc"                     
# [85] "unhideSheet"                     "unmergeCells"                   
# [87] "writeNamedRegion"                "writeNamedRegionToFile"         
# [89] "writeWorksheet"                  "writeWorksheetToFile"           
# [91] "XLC"                             "xlcDump"                        
# [93] "xlcEdit"                         "xlcFreeMemory"                  
# [95] "xlcMemoryReport"                 "xlcRestore"   

Runninghelp("XLConnect")提供了一个示例来帮助您入门,并且网络上有更多材料。具体来说,我认为您正在寻找writeWorksheet-function。

于 2018-04-05T19:43:48.047 回答