SetOutputOptions Method (Python)
Sets export options for this output document. These options apply
when exporting with the ExportDocument
method from the SpssOutputDoc
class as well as the ExportToDocument
method from the SpssOutputItem
class.
Syntax
SpssOutputDoc.SetOutputOptions(option,setting)
Parameters
The available values for the option parameter as well as the allowed values of the associated setting are (specify the name of the option without quotes):
SpssClient.DocExportOption.ExcelSheetNames. The setting is a string specifying the name of the sheet to which items will be exported. Sheet names cannot exceed 31 characters and cannot contain forward or back slashes, square brackets, question marks, or asterisks. If the specified worksheet doesn't exist in the Excel file, a new worksheet with that name will be created. This option only applies when exporting to Excel. The default worksheet is "Sheet1".
SpssClient.DocExportOption.ExcelStartingCell. The setting is a string specifying the starting cell, as in "B3".
Applies when SpssClient.DocExportOption.ExcelLocationOptions
is set to "OverwriteAtCellRef". Only applies when exporting to Excel.
The default starting cell is A1.
SpssClient.DocExportOption.ExcelOperationOptions. The setting is a string specifying whether a new workbook is created, a new worksheet is created, or an existing worksheet is modified. This option only applies when exporting to Excel.
- "CreateWorkbook". A new workbook is created. This is the default. If the specified file exists, it is overwritten.
-
"CreateWorksheet". A new worksheet is created within the specified workbook. The name
of the sheet is given by the setting of
SpssClient.DocExportOption.ExcelSheetNames
. If a worksheet with the specified name already exists, that worksheet is overwritten. If the specified file does not exist, a new file is created with a worksheet with the specified name. -
"ModifyWorksheet". Modifies the contents of an existing worksheet. The name of the
sheet is given by the setting of
SpssClient.DocExportOption.ExcelSheetNames
. UseSpssClient.DocExportOption.ExcelLocationOptions
andSpssClient.DocExportOption.ExcelStartingCell
to specify location in the sheet. Export of charts, model views, and tree diagrams is not supported with "ModifyWorksheet".
SpssClient.DocExportOption.ExcelLocationOptions. A string specifying how items will be added to a worksheet. This option only applies when exporting to Excel.
- "AddColumns". Specifies that items will be added after the last column, starting in the first row, without modifying any existing contents. This is the default.
- "AddRows". Specifies that items will be added after the last row, starting in the first column, without modifying any existing contents.
-
"OverwriteAtCellRef". Specifies that items will be written to the location specified in
SpssClient.DocExportOption.ExcelStartingCell
. Any existing content in the area where the exported items are added will be overwritten.
SpssClient.DocExportOption.WideTablesOptions. A string specifying the treatment of pivot tables that are too wide for the document width (the specified page width minus the left and right margins). This option only applies when exporting to Word or PowerPoint.
- "WT_Wrap". Specifies that tables are divided into sections that will fit within the defined document width. This is the default. Row labels are repeated for each section of the table. If the row labels are too wide for the defined document width, the table is exported without wrapping and will appear truncated in the document.
- "WT_Shrink". Specifies that font size and column width are reduced so that tables fit within the document width.
- "WT_Extend". Specifies that tables that are too wide for the document width will appear truncated. All of the table content, however, is retained so expanding the document width will display additional table content.
The following options apply when exporting to Word or PowerPoint.
SpssClient.DocExportOption.ItemsPageHeight. A character representation of a positive number representing the
page height, in units specified by SpssClient.DocExportOption.ItemsMeasurementUnits
.
SpssClient.DocExportOption.ItemsPageWidth. A character representation of a positive number representing the
page width, in units specified by SpssClient.DocExportOption.ItemsMeasurementUnits
.
SpssClient.DocExportOption.ItemsTopMargin. A character representation of a positive number representing the
top margin, in units specified by SpssClient.DocExportOption.ItemsMeasurementUnits
.
SpssClient.DocExportOption.ItemsBottomMargin. A character representation of a positive number representing the
bottom margin, in units specified by SpssClient.DocExportOption.ItemsMeasurementUnits
.
SpssClient.DocExportOption.ItemsRightMargin. A character representation of a positive number representing the
right margin, in units specified by SpssClient.DocExportOption.ItemsMeasurementUnits
.
SpssClient.DocExportOption.ItemsLeftMargin. A character representation of a positive number representing the
left margin, in units specified by SpssClient.DocExportOption.ItemsMeasurementUnits
.
SpssClient.DocExportOption.ItemsMeasurementUnits. A string specifying the units for page dimensions and margins: "IExportOptions.MeasurementUnits.Inches", "IExportOptions.MeasurementUnits.Millimeters", "IExportOptions.MeasurementUnits.Centimeters", and "IExportOptions.MeasurementUnits.PrintPoints" (1/72 inch). The default is "IExportOptions.MeasurementUnits.Inches".
Example
This example assumes that OutputDoc
is an SpssOutputDoc
object
and exports all pivot tables to an existing Excel worksheet beginning
at a specified location.
OutputDoc = SpssClient.GetDesignatedOutputDoc()
OutputDoc.SetOutputOptions(SpssClient.DocExportOption.ExcelSheetNames,"mysheet")
OutputDoc.SetOutputOptions(SpssClient.DocExportOption.ExcelStartingCell,"B6")
OutputDoc.SetOutputOptions(SpssClient.DocExportOption.ExcelLocationOptions,
"OverwriteAtCellRef")
OutputDoc.SetOutputOptions(SpssClient.DocExportOption.ExcelOperationOptions,
"ModifyWorksheet")
OutputItems = OutputDoc.GetOutputItems()
for index in range(OutputItems.Size()):
OutputItem = OutputItems.GetItemAt(index)
if OutputItem.GetType() == SpssClient.OutputItemType.PIVOT:
OutputItem.SetSelected(True)
OutputDoc.ExportDocument(SpssClient.SpssExportSubset.SpssSelected,
"/output/myexport.xls",
SpssClient.DocExportFormat.SpssFormatXls)