setDataFormatForType-methods
From XLConnect v1.0.1
by Martin Studer
Setting the data format for the DATA_FORMAT_ONLY style action
Sets the data format for a specific data type as used by the DATA_FORMAT_ONLY style action.
Usage
# S4 method for workbook
setDataFormatForType(object,type,format)
Arguments
Details
Based on the (cell) data type the DATA_FORMAT_ONLY style action (see setStyleAction
)
sets the data format for the corresponding cells. The data type
is normally specified via a
corresponding data type constant from the XLC
object. Data formats are specified the standard
Excel way. Refer to the Excel help or to the link below for more information.
References
Excel custom data formats: http://www.ozgrid.com/Excel/CustomFormats.htm
See Also
'>workbook
, setStyleAction
Examples
# NOT RUN {
# Copy existing Excel template to working directory
file.copy(system.file("demoFiles/template2.xlsx",
package = "XLConnect"),
"dataformat.xlsx", overwrite = TRUE)
# Load workbook
wb <- loadWorkbook("dataformat.xlsx")
# Set the data format for numeric columns (cells)
# (keeping the defaults for all other data types)
setDataFormatForType(wb, type = XLC$"DATA_TYPE.NUMERIC",
format = "0.00")
# Set style action to 'data format only'
setStyleAction(wb, XLC$"STYLE_ACTION.DATA_FORMAT_ONLY")
# Write built-in data set 'mtcars' to the named region
# 'mtcars' as defined by the Excel template.
writeNamedRegion(wb, mtcars, name = "mtcars")
# Save workbook
saveWorkbook(wb)
# clean up
file.remove("dataformat.xlsx")
# }
Community examples
Looks like there are no examples yet.