2.11.1 Exporting WorksheetsExporting-Worksheets
Export a WorksheetExport WorksheetWorksheet Export
Your worksheet data may be exported either as an image (i.e., PDF) or as a data file.
Export a Worksheet as an Image File
The expWks X-Function can be used to export the entire worksheet, the visible area of the worksheet, or worksheet selection, to an image file such as JPEG, EPS, or PDF:
// Export the active worksheet to an EPS file named TEST.EPS,
// saved to the D:\ drive.
expWks type:=EPS export:=active filename:="TEST" path:="D:";
The expWks X-Function also provides options for exporting many worksheets at the same time using the export option, which if unspecified simply exports the active worksheet.
In the following example, export:=book exports all worksheets in the current workbook to the desired folder path:
expWks type:=PDF export:=book path:="D:\TestImages" filename:=Sheet#;
Worksheets are saved in the order they appear in the workbook from left to right. Here, the naming has been set to number the sheets in that order, as in 'Sheet1', 'Sheet2', etc. If more than 9 sheets exist, filename:=Sheet## will yield names such as 'Sheet01'.
Other options for export are project, recursive, folder, and specified.
The expWks X-Function is particularly useful in exporting custom report worksheets that user may create by placing graphs and other relevant analysis results in a single sheet for presentation, using formatting features such as merging and coloring cells.
Export a Worksheet as a Multipage PDF File
The expPDFw X-Function allows exporting worksheets to multi-page PDF files. This X-Function is then useful to export large worksheets, including custom report sheets, where the worksheet has more content than can fit in one page for the current printer settings. This X-Function offers options such as printing all sheets in a book or all sheets in the project, and options for including a cover page and adding page numbering.
Export a Worksheet as a Data File
In this example, worksheet data is output to an ASCII file with tabs separating the columns using the expAsc X-Function:
// Export the data in Book 2, Worksheet 3 using tab-separators to
// an ASCII file named TEST.DAT, saved to the D:\ drive.
expASC iw:=[Book2]Sheet3 type:=0 path:="D:\TEST.DAT" separator:=TAB;
Note, in this example, that type simply indicates the type of file extension, and may be set to any of the following values (type:=dat is equivalent to type:=0):
- 0=dat:*.dat,
- 1=text:Text File(*.txt),
- 2=csv:*.csv,
- 3=all:All Files(*.*)
More examples can be found here.
|