setDataFormatForType-methods

0th

Percentile

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.

Keywords
methods, utilities
Usage
# S4 method for workbook
setDataFormatForType(object,type,format)
Arguments
object

The '>workbook to use

type

The data type for which to set the format.

format

A data format string

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

Aliases
  • setDataFormatForType
  • setDataFormatForType-methods
  • setDataFormatForType,workbook-method
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)
# }
Documentation reproduced from package XLConnect, version 0.2-14, License: GPL-3

Community examples

Looks like there are no examples yet.