找回密码
 注册
查看: 802|回复: 0

R语言 XLConnect包 cellstyle-class()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 23:20:02 | 显示全部楼层 |阅读模式
cellstyle-class(XLConnect)
cellstyle-class()所属R语言包:XLConnect

                                        Class "cellstyle"
                                         类“cellstyle”

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This class represents a cell style in a Microsoft Excel workbook. S4 objects of this class and corresponding methods are used to manipulate cell styles. This includes setting data formats, borders, background- and foreground-colors, etc.
这个类表示一个单元格样式在Microsoft Excel中workbook。 S4对象的类和相应的方法被用来操纵单元格样式。这包括设置数据格式,边框,背景和前景颜色,等等。


类对象----------Objects from the Class----------

Cell styles are created by calling the createCellStyle method on a workbook object.
单元格样式创建通过调用createCellStyle方法,在workbook对象。


插槽----------Slots----------




jobj: Object of class jobjRef (see package rJava) which represents a Java object reference that is used
jobj:类的对象jobjRef(见套件“rJava)这是一个Java对象引用使用


注意----------Note----------

XLConnect generally makes use of custom (named) cell styles. This allows users to more easily manage cell styles via Excel's cell style menu. For example, assuming you were using a specific custom cell style for your data table headers, you can change the header styling with a few clicks in Excel's cell style menu across all tables.
XLConnect通常使用的自定义(命名)的单元格样式。这使得用户更容易管理的单元格样式通过Excel的单元格样式菜单。例如,假设你使用的是特定的自定义单元格样式,为您的数据表头,可以改变头的造型在所有表在Excel的单元格样式菜单点击几下。


(作者)----------Author(s)----------



Martin Studer<br>
Mirai Solutions GmbH <a href="http://www.mirai-solutions.com">http://www.mirai-solutions.com</a>




参考文献----------References----------

http://bit.ly/c1VUZ6<br> Cell styles in Excel 2007:<br> http://bit.ly/gj1KRx

参见----------See Also----------

workbook, createCellStyle, setStyleAction, setCellStyle
workbook,createCellStyle,setStyleAction,setCellStyle


实例----------Examples----------


# Load workbook (create if not existing)[负载工作簿(如果不存在创建)]
wb <- loadWorkbook("cellstyles.xlsx", create = TRUE)

# We don't set a specific style action in this demo, so the [我们在本演示中没有设置特定风格的动作,所以]
# default 'XLConnect' will be used (XLC$"STYLE_ACTION.XLCONNECT")[将用于默认的“XLConnect”,(XLC的“STYLE_ACTION.XLCONNECT”)]

# Create a sheet named 'mtcars'[创建一张名为“mtcars”]
createSheet(wb, name = "mtcars")

# Create a named region called 'mtcars' referring to the sheet[创建一个命名区域被称为“mtcars”指的是纸张]
# called 'mtcars'[被称为“mtcars”]
createName(wb, name = "mtcars", formula = "mtcars!$C$4")

# Write built-in data set 'mtcars' to the above defined named region.[写内置的数据集mtcars上述定义的命名区域。]
# This will use the default style action 'XLConnect'.[这将使用默认的样式的行动“XLConnect”。]
writeNamedRegion(wb, mtcars, name = "mtcars")

# Now let's color all weight cells of cars with a weight &gt; 3.5 in red[现在,让我们所有汽车的重量单元的颜色为红色,重量> 3.5]
# (mtcars$wt &gt; 3.5)[(mtcars重量> 3.5)]

# First, create a corresponding (named) cell style[首先,创建一个对应的单元格样式(命名)]
heavyCar <- createCellStyle(wb, name = "HeavyCar")

# Specify the cell style to use a solid foreground color[指定的单元格样式,使用了坚实的前景色]
setFillPattern(heavyCar, fill = XLC$"FILL.SOLID_FOREGROUND")

# Specify the foreground color to be used[指定要使用的前景色]
setFillForegroundColor(heavyCar, color = XLC$"COLOR.RED")

# Which cars have a weight &gt; 3.5 ?[该款车的重量> 3.5?]
rowIndex <- which(mtcars$wt > 3.5)

# NOTE: The mtcars data.frame has been written offset with top [注:mtcars数据框已被写入偏移顶部]
# left cell C4 - and we have also written a header row![左边的单元格C4  - 我们也写了一个标题行!]
# So, let's take that into account appropriately. Obviously,[所以,让我们适当考虑到这一点。很显然,]
# the two steps could be combined directly into one ...[两个步骤可以被组合成一个直接...]
rowIndex <- rowIndex + 4

# The same holds for the column index[面临着同样的列索引]
colIndex <- which(names(mtcars) == "wt") + 2

# Set the 'HeavyCar' cell style for the corresponding cells.[设置“HeavyCar相应的单元格的单元格样式。]
# Note: the row and col arguments are vectorized![注:ROW和COL参数量化的!]
setCellStyle(wb, sheet = "mtcars", row = rowIndex, col = colIndex,
             cellstyle = heavyCar)

# Save workbook (this actually writes the file to disk)[保存工作簿(这实际上是将文件写入到磁盘)]
saveWorkbook(wb)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-24 21:22 , Processed in 0.019682 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表