IR Framework

Section.ExportToExcel Method

The ExportToExcel method exports data from a Results, Table, or Pivot to Excel.
object.ExportToExcel (directory, filename[, openwhendone[, unmerge[, unpivot]]])

Arguments

object
Required. A Results, Table, or Pivot object.

directory
Required. The path to the directory where the exported file will be saved.

filename
Required. The name of the exported file without the extension.

openwhendone
Optional. A boolean value indicating whether to display the exported file in Excel when the export is complete.

unmerge
Optional. A boolean value indicating whether to unmerge the cells when the data is exported. This will also remove row and column totals.

unpivot
Optional. A boolean value indicating whether to unpivot the data when it is exported. This will also remove row and column totals.


Remarks

If the section is a Pivot and unmerge and/or unpivot are not provided, the user will be presented with a dialog asking them if they want the data unmerged or unpivotted.

This method exports formatted data from Results and Tables. If the section is a Pivot, formatting is kept if the data is exported as-is.

Formatted data is exported to MIME HTML (.mht) format with a reference indicating that the contents are intended for Excel.

Unformatted data is exported to Excel 97-2003 (.xls) format.

If a file of the same name already exists at directory, it will be overwritten.



Example:
//	export a section to Excel
//	This will create a file at c:\myfolder\ExcelExportTest.xls.mht
ActiveDocument.Sections["Results"].ExportToExcel("c:\\myfolder\\", "ExcelExportTest.xls", true);
//	This will create a file at c:\myfolder\ExcelExportTest.xls.xls
//	The data will be unpivotted.  Any top labels will be made row labels and placed to the 
//	left of the existing row labels.  Row and column totals will be omitted and cells will not be merged.
ActiveDocument.Sections["Pivot"].ExportToExcel("c:\\myfolder\\", "ExcelExportTest.xls", true, true, true);
//	This will create a file at c:\myfolder\ExcelExportTest.xls.xls
//	The user will be asked how to process the export.
ActiveDocument.Sections["Pivot"].ExportToExcel("c:\\myfolder\\", "ExcelExportTest.xls", true);




Requirements

ActiveDocument.loadObjectMethods() must be run for this method to be available.
Microsoft Excel must be installed on the computer running the script.