% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xl_table.R
\name{xl_table_column}
\alias{xl_table_column}
\title{Describe a column of a worksheet table}
\usage{
xl_table_column(
  col,
  header = NULL,
  formula = NULL,
  total = NULL,
  total_label = NULL,
  total_value = NULL,
  format = NULL,
  header_format = NULL
)
}
\arguments{
\item{col}{The column: a name or a 1-based position within the table's range.}

\item{header}{The header caption.  Defaults to the data frame's column name
--- which is also what makes a table safe to add, since Excel rejects a
file whose table definition and header cells disagree.}

\item{formula}{A formula filling every data cell of the column, usually with
a structured reference such as `"=SUM(Sales[@[Q1]:[Q4]])"`.  Because those
name the table, see the `name` argument of [xl_table()].}

\item{total}{The function shown in this column's total-row cell: one of
`"sum"`, `"average"`, `"count"`, `"count_nums"`, `"max"`, `"min"`,
`"std_dev"` or `"var"`.  Needs `total_row = TRUE` on the table.}

\item{total_label}{A string for the total-row cell instead of a function ---
typically `"Total"` under the first column.}

\item{total_value}{The number the total-row cell already holds. Excel
recalculates `total` on open and ignores this, but a reader that does not
evaluate formulas --- [readxl::read_xlsx()] among them --- shows what is
cached, which without this is nothing.}

\item{format}{An [xl_format] applied to the column's data cells.}

\item{header_format}{An [xl_format] applied to the column's header cell.}
}
\value{
An `xl_table_column` object.
}
\description{
`xl_table_column()` overrides what [xl_table()] does with one column: its
header caption, a formula filling the column, what its total-row cell shows,
and the formats applied to the header and the data cells.

Only the columns you name need an entry; the rest take the data frame's
column name as their header and are left otherwise alone.
}
\examples{
xl_table_column("qty", total = "sum")
xl_table_column("fruit", total_label = "Total")
xl_table_column("margin", formula = "=Sales[@revenue] * 0.3")
}
\seealso{
[xl_table], [xl_sheet]

Other worksheet features:
\code{\link{xl_conditional}},
\code{\link[=xl_filter]{xl_filter()}},
\code{\link[=xl_filter_keep]{xl_filter_keep()}},
\code{\link[=xl_merge]{xl_merge()}},
\code{\link[=xl_table]{xl_table()}},
\code{\link[=xl_validation]{xl_validation()}}
}
\concept{worksheet features}
