Hi, I need to format some cells in a pivot table as, for instance, (15.6) instead of 15.6, so trying to use the custom currency format (CCA, ..., CCE) by defining it using SetPreference method. Below is my code and I can see that SetPreference lines are working, but it is giving the error as "Not a valid argument value" for the last line (SetNumericFormatAt). I have also tried using "(#.###) : −(#.###)" instead of "CCA" in the last line. Can anyone please tell me what is being wrong here?
begin program.
import spss, spssaux
import SpssClient
SpssClient.StartClient()
SpssClient.SetPreference(SpssClient.PreferenceOptions.CustomOutputFormat,"CCA")
SpssClient.SetPreference(SpssClient.PreferenceOptions.AllValuesPrefix,"(")
SpssClient.SetPreference(SpssClient.PreferenceOptions.AllValuesSuffix,")")
SpssClient.SetPreference(SpssClient.PreferenceOptions.NegativeValuesPrefix,"-")
SpssClient.SetPreference(SpssClient.PreferenceOptions.NegativeValuesSuffix,"")
SpssClient.SetPreference(SpssClient.PreferenceOptions.DecimalSeparator,"period")
oDoc = SpssClient.GetDesignatedOutputDoc()
oItems = oDoc.GetOutputItems()
for index in range(oItems.Size()):
oItem = oItems.GetItemAt(index)
if oItem.GetType() == SpssClient.OutputItemType.PIVOT:
pTable = oItem.GetSpecificType()
datacells = pTable.DataCellArray()
RowLabels = pTable.RowLabelArray()
for i in range(datacells.GetNumRows()):
if float(datacells.GetValueAt(i,2)) >= 25 and float(datacells.GetValueAt(i,2)) < 500:
datacells.SetNumericFormatAt(i,0,"CCA")
end program.
Much apprecieted,
Zula
------------------------------
Munkhzul Zookhuu
------------------------------
#SPSSStatistics