logo

img

Knowledgebase Home | Contact Knowledgebase Home | Contact
Search the Knowledgebase Browse by Category
How can I specify a particular Excel worksheet to load in Scripter?
User Opinions
No users have voted.

How would you rate this answer?
Helpful
Not helpful
To specify a particular worksheet in an Excel XLS or XLSX file, use the DataFileOptions parameter of the "2" method when loading the data file (ie. GridData2, CrossValidate2, AddPostMap2, AddClassedPostMap2, AddVariogram2, SetInputData2, GridResiduals2, Transform2).

For example, to grid a sheet in an excel workbook, instead of using GridData, use GridData2 and specify the DataFileOptions.

**********

Sub Main
    
   Dim SurferApp As Object
   Set SurferApp = CreateObject("Surfer.Application")
   SurferApp.Visible = True

'Grids the data in a specific sheet in an Excel workbook and creates a grid file
    SurferApp.GridData2(DataFile:="c:\temp\book1.xlsx",DataFileOptions:="sheet=sheet2", _
    Algorithm:=1, ShowReport:=False, OutGrid:="c:\temp\Demogrid.grd")

'Creates a cross validation report from the data in a specific sheet in an Excel workbook and saves it to a file
    SurferApp.CrossValidate2(DataFile:="c:\temp\book1.xlsx", DataFileOptions:="sheet=sheet2", _
    Algorithm:=1, ShowReport:=False, ResultsFile:="c:\temp\CrossValidate.dat")

'Creates the contour map from the grid file
    Dim Doc As Object
    Set Doc = SurferApp.Documents.Add
    Dim Map As Object
    Set Map = Doc.Shapes.AddContourMap(GridFileName:="c:\temp\Demogrid.grd")

'Creates a post map from the sheet in the Excel workbook
    Set Map2 = Doc.Shapes.AddPostMap2(DataFileName:="c:\temp\book1.xlsx", DataFileOptions:="sheet=sheet2")

End Sub
Visitor Comments
No visitor comments posted. Post a comment
Related Questions
Attachments
No attachments were found.
Products