SetDefaultFormatSpec Method (R)
.SetDefaultFormatSpec(object,formatSpec,varIndex). Sets the default format for CellText.Number
objects. The argument object is a reference to the associated
BasePivotTable object. The argument formatSpec is of the form formatSpec.format where format is one of those
listed in Table 1--for example, formatSpec.Mean. The argument varIndex is the index of a variable in the
active dataset whose format is used to determine details of the resulting
format. varIndex is only used for,
and required by, the following subset of formats: Mean, Variable, StdDev, Difference, and Sum. Index values represent position in the active dataset, starting
with 0 for the first variable in file order. The default format can
be retrieved with the GetDefaultFormatSpec method.- Instances of the
BasePivotTableclass have an implicit default format ofGeneralStat.
Example
table = spss.BasePivotTable("Table Title",
"OMS table subtype")
BasePivotTable.SetDefaultFormatSpec(table,formatSpec.Mean,2)
rowdim=BasePivotTable.Append(table,Dimension.Place.row,"rowdim")
coldim=BasePivotTable.Append(table,Dimension.Place.column,"coldim")
row_cat1 = spss.CellText.String("row1")
row_cat2 = spss.CellText.String("row2")
col_cat = spss.CellText.String("col1")
BasePivotTable.SetCategories(table,rowdim,list(row_cat1,row_cat2))
BasePivotTable.SetCategories(table,coldim,col_cat)
BasePivotTable.SetCellValue(table,list(row_cat1,col_cat),spss.CellText.Number(2.37))
BasePivotTable.SetCellValue(table,list(row_cat2,col_cat),spss.CellText.Number(4.34))
- The call to
SetDefaultFormatSpecspecifies that the format for mean values is to be used as the default, and that it will be based on the format for the variable with index value 2 in the active dataset. Subsequent instances ofCellText.Numberwill use this default, so the cell values2.37and4.34will be formatted as mean values.