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

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

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

                                        Controlling application of cell styles when writing data to Excel
                                         控制应用程序时写入数据到Excel的单元格样式

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

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

Controls the application of cellstyles when writing data to Excel.
控制应用程序写入数据到Excel时,cellstyle的。


用法----------Usage----------


## S4 method for signature 'workbook'
setStyleAction(object,type)



参数----------Arguments----------

参数:object
The workbook to use
workbook使用


参数:type
Defines the style action to be used when writing data (writeNamedRegion, writeWorksheet) to the specified workbook object
写作时要使用指定的工作簿writeNamedRegion数据(writeWorksheet,object)的,以定义风格的动作


Details

详细信息----------Details----------

The following style actions are supported:<br>
下面的样式行动支持:参考

XLC$"STYLE_ACTION.XLCONNECT": This is the default. data.frame headers (if specified to be written) are colored in solid light grey (25 percent). character, numeric and logical vectors are written using Excel's "General" data format. Time/date vectors e.g. Date or POSIXt) are written with the "mm/dd/yyyy hh:mm:ss" data format. All cells are specified to wrap the text if necessary. The corresponding custom cell styles are called XLConnect.Header, XLConnect.General and XLConnect.Date.
XLC$"STYLE_ACTION.XLCONNECT":这是默认的。 data.frame头(如果指定要写入)的颜色,在固体浅灰色(25%)。用Excel的“常规”数据格式字符,数字和逻辑向量。时间/日期向量如Date或POSIXt)写的“MM / DD / YYYY HH:MM:SS”的数据格式。如有必要,所有的单元都指定文本换。相应的自定义单元格样式被称为XLConnect.Header,XLConnect.General XLConnect.Date。

XLC$"STYLE_ACTION.NONE": This style action instructs XLConnect to apply no cell styles when writing data. Cell styles are kept as they are. This is useful in a scenario where all styling is predefined in an Excel template which is then only filled with data.
XLC$"STYLE_ACTION.NONE":这种风格的动作指示XLConnect申请没有写入数据时的单元格样式。单元格样式保持原样。在一个场景中,所有的造型是预定义的Excel模板,那么只有用数据填充,这是非常有用的。

XLC$"STYLE_ACTION.PREDEFINED": This style action instructs XLConnect to use existing (predefined) cellstyles when writing headers and columns. This is useful in a template-based approach where an Excel template with predefined cellstyles for headers and columns is available. Normally, this would be used when the column dimensions (and potentially also the row dimensions) of the data tables are known up-front and as such a layout and corresponding cell styles can be pre-specified.<br> If a data.frame is written including its header, it is assumed that the Excel file being written to has predefined cellstyles in the header row. Furthermore, the first row of data is assumed to contain the cell styles to be replicated for any additional rows. As such, this style action may only be useful if the same column cell style should be applied across all rows. Please refer to the available demos for some examples.
XLC$"STYLE_ACTION.PREDEFINED":这种风格的动作指示XLConnect使用现有的(预定义的)cellstyle的时候写头和列。这是非常有用的,在一个基于模板的方法,其中一个Excel模板与预定义的cellstyle的头和列。通常情况下,这将柱尺寸(和潜在的也行尺寸)的数据表时使用的是已知的正面和作为这样的布局和相应的单元格样式可以被预先指定。<br>如果一个<X >写的,包括它的头,它是假定,被写入Excel文件的标题行中有预定义的data.frame的。此外,第一行的数据被假定为包含要被复制的任何额外的行的单元格样式。因此,这种风格的动作只可能是有用的,如果在同一列的单元格样式应适用于所有行。请参阅可用的一些实施例中的演示。

XLC$"STYLE_ACTION.NAME_PREFIX": This style action instructs XLConnect to look for custom (named) cellstyles with a specified prefix when writing columns and headers. This style name prefix can be set via the method setStyleNamePrefix.<br>
XLC$"STYLE_ACTION.NAME_PREFIX":这种风格的动作指示XLConnect寻找自定义(命名为)cellstyle的S列和标题写作时指定的前缀。这可以通过设置样式名称前缀的方法setStyleNamePrefix。<BR>

For column headers, it first checks if there is a cell style named<br> <VAR><STYLE_NAME_PREFIX>.Header.<COLUMN_NAME></VAR>.<br> If there is no such cell style,  it checks for a cell style named<br> <VAR><STYLE_NAME_PREFIX>.Header.<COLUMN_INDEX></VAR>.<br> Again, if there is no such cell style, it checks for<br> <VAR><STYLE_NAME_PREFIX>.Header</VAR><br> (no specific column discrimination). As a final resort, it just takes the workbook default cell style.<br>
列标题,它首先会检查是否有一个单元格样式名为“<BR> <VAR> <STYLE_NAME_PREFIX>头。<COLUMN_NAME> </ VAR>:。<BR>如果没有这样的单元格样式,它会检查单元格样式名为“<BR> <VAR> <STYLE_NAME_PREFIX>。头。<COLUMN_INDEX>,</ VAR>。参考同样,如果没有这样的单元格样式,它检查为<BR> <VAR>头STYLE_NAME_PREFIX> </ VAR>参考(没有具体列歧视)。作为最后的手段,它只是需要工作簿的默认单元格样式。<BR>

For columns, XLConnect first checks the availability of a cell style named<br> <VAR><STYLE_NAME_PREFIX>.Column.<COLUMN_NAME></VAR>.<br> If there is no such cell style, it checks for<br> <VAR><STYLE_NAME_PREFIX>.Column.<COLUMN_INDEX></VAR>.<br> If again there is no such cell style, it checks for<br> <VAR><STYLE_NAME_PREFIX>.Column.<COLUMN_DATA_TYPE></VAR><br> with <VAR><COLUMN_DATA_TYPE></VAR> being the corresponding data type from the set:  <VAR>{Numeric, String, Boolean, DateTime}</VAR>. As a last resort, it would make use of the workbook's default cell style.
对于列,XLConnect先检查单元格样式名为“<BR> <VAR> <STYLE_NAME_PREFIX>的可用性。列。<COLUMN_NAME>,</ VAR>。<BR>如果没有这样的单元格样式,它会检查的<BR> <VAR> <STYLE_NAME_PREFIX>。列。<COLUMN_INDEX>,</ VAR>。<BR>如果再没有这样的单元格样式,检查<BR> <VAR> <STYLE_NAME_PREFIX>的列“。<COLUMN_DATA_TYPE> </ VAR>参考<VAR> <COLUMN_DATA_TYPE> </ VAR>相应的数据类型的设置:<VAR> {数字,字符串,布尔,日期} </ VAR >。作为最后的手段,它将使使用工作簿的默认单元格样式。

XLC$"STYLE_ACTION.DATA_FORMAT_ONLY": This style action instructs XLConnect to only set the data format for a cell but not to apply any other styling but rather keep the existing one. The data format to apply is determined by the data type of the cell (which is in turn determined by the corresponding R data type). The data format for a specific type can be set via the method setDataFormatForType. The default data format is "General" for the data types <VAR>Numeric</VAR>, <VAR>String</VAR> and <VAR>Boolean</VAR> and is "mm/dd/yyyy hh:mm:ss" for the data type <VAR>DateTime</VAR>.
XLC$"STYLE_ACTION.DATA_FORMAT_ONLY":这种风格的动作指示XLConnect只设置数据格式为一个单元,但不适用任何其他的造型,而是保持现有的。适用的数据格式的数据的单元的类型(它是依次由相应的R数据类型确定)确定。方法setDataFormatForType可以通过设置为特定类型的数据格式。的默认数据格式的数据类型<VAR>数字</ VAR>,<VAR>字符串</ VAR>和<VAR>布尔</ VAR>“常规”和“MM / DD / YYYY HH: MM:SS“的数据类型<VAR>的DateTime </ VAR>。


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



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




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

workbook, cellstyle, createCellStyle, writeNamedRegion, writeWorksheet, setStyleNamePrefix, setDataFormatForType
workbook,cellstyle,createCellStyle,writeNamedRegion,writeWorksheet,setStyleNamePrefix,setDataFormatForType


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


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

# Set style action to 'name prefix' [风格的动作设置“名称的前缀]
setStyleAction(wb, XLC$"STYLE_ACTION.NAME_PREFIX")
# Set the name prefix to 'MyPersonalStyle'[将名称前缀MyPersonalStyle“]
setStyleNamePrefix(wb, "MyPersonalStyle")

# We now create a named cell style to be used for the header [我们现在可以创建一个命名的单元格样式将用于标题]
# (column names) of a data.frame[(列名)的数据框]
headerCellStyle <- createCellStyle(wb,
                             name = "MyPersonalStyle.Header")

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

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

# Specify a thick black bottom border[指定一个厚厚的黑色底边框]
setBorder(headerCellStyle, side = "bottom",
          type = XLC$"BORDER.THICK",
          color = XLC$"COLOR.BLACK")

# We now create a named cell style to be used for [我们现在用于创建一个命名的单元格样式]
# the column named 'wt' (as you will see below, we will [列名为“重量”(下面你会看到,我们将]
# write the built-in data.frame 'mtcars')[写内置的数据框mtcars)]
wtColumnCellStyle <- createCellStyle(wb,
                           name = "MyPersonalStyle.Column.wt")

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

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

# We now create a named cell style to be used for [我们现在用于创建一个命名的单元格样式]
# the 3rd column in the data.frame[第三列中的数据框]
wtColumnCellStyle <- createCellStyle(wb,
                            name = "MyPersonalStyle.Column.3")

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

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

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

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

# Write built-in data set 'mtcars' to the above defined named region.[写内置的数据集mtcars上述定义的命名区域。]
# The style action 'name prefix' will be used when writing the data[在写入数据时,将使用风格的动作的名称前缀“]
# as defined above.[如上所定义。]
writeNamedRegion(wb, mtcars, name = "mtcars")

# 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 18:37 , Processed in 0.023426 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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