Section.ExportToExcel MethodThe ExportToExcel method exports data from a Results, Table, or Pivot to Excel.object.ExportToExcel (directory, filename[, openwhendone[, unmerge[, unpivot]]]) Arguments
RemarksIf 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); RequirementsActiveDocument.loadObjectMethods() must be run for this method to be available.Microsoft Excel must be installed on the computer running the script. |