如何使用xlsx(R包)设置特定单元格的值? [英] How do I set the value of a specific cell using xlsx (R package)?

查看:80
本文介绍了如何使用xlsx(R包)设置特定单元格的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在xlsx中设置特定单元格的值.我这样做是为了为在Excel中添加的数据框添加标题,但是我无法弄清楚.我尝试了createCellscreateRowsgetCellsgetRows,但是尽管阅读了文档,但似乎无法使它们中的任何一个起作用.

I'm trying to set the value of a specific cell in xlsx. I'm doing this to add a title for the data frame that I added in Excel, but I can't figure it out. I tried createCells, createRows, getCells and getRows, but I can't seem to get any of them to work despite reading the documentation.

推荐答案

我看不到代码,也没有确切知道要执行的操作,因此建议尝试

Without benefit of seeing your code and knowing exactly what you are trying to do, I suggest trying

setCellValue(cell, value)

例如,从头开始并创建一个新的excel文件:

For example, starting from scratch and creating a new excel file:

wb    <- createWorkbook(type="xlsx")           # create an empty workbook
sheet <- createSheet(wb, sheetName="Sheet1")   # create an empty sheet 
rows  <- createRow(sheet, rowIndex=1:10)       # 10 rows
cells <- createCell(rows, colIndex=1:6)        # 6 columns in each row
setCellValue(cells[[1,2]], "Data Frame Title Goes Here")   # put in Row 1, Column 2

这篇关于如何使用xlsx(R包)设置特定单元格的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆