This article contains a sample script for choosing a specific sheet in an Excel XLS file to use for gridding.
To run this script:
- Copy the script below, or download the attached BAS file: Multisheet XLS.bas.
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Click Script | Run to run the script.
*********
'Multisheet XLS.bas shows how to specify a particular sheet in 'an Excel XLS or XLSX file to use for gridding. '===================================== Sub Main Dim SurferApp As Object Set SurferApp = CreateObject("Surfer.Application") SurferApp.Visible = True Dim Plot As Object Set Plot = SurferApp.Documents.Add(srfDocPlot) 'Use GridData2 to grid data and specify data file options, such as XLS sheet name SurferApp.GridData2("c:\temp\Book1.xlsx", DataFileOptions:="sheet=Test", ShowReport:=False, OutGrid:="c:\temp\test.grd") 'Create a contour map from the grid file Plot.Shapes.AddContourMap(GridFileName:="c:\temp\test.grd") 'Use AddPostMap2 to create a post map from a data file and specify data file options, such as XLS sheet name Plot.Shapes.AddPostMap2("c:\temp\Book1.xlsx", DataFileOptions:="sheet=Test") Plot.Shapes.SelectAll Plot.Selection.OverlayMaps End Sub
Updated November 13, 2018
Comments
0 comments
Please sign in to leave a comment.