![](/profiles/wavemetrics/themes/wavemetrics/logo.png)
Load Excel Data Into Matrix
![](/sites/default/files/styles/thumbnail/public/default_images/Artboard%201_1.png?itok=jeHOCIXy)
![](/profiles/wavemetrics/themes/wavemetrics/images/icons/employee-icon.png)
hrodstein
Function LoadExcelNumericDataAsMatrix(pathName, fileName, worksheetName, startCell, endCell)
String pathName // Name of Igor symbolic path or "" to get dialog
String fileName // Name of file to load or "" to get dialog
String worksheetName
String startCell // e.g., "B1"
String endCell // e.g., "J100"
if ((strlen(pathName)==0) || (strlen(fileName)==0))
// Display dialog looking for file.
Variable refNum
String filters = "Excel Files (*.xls,*.xlsx,*.xlsm):.xls,.xlsx,.xlsm;"
filters += "All Files:.*;"
Open/D/R/P=$pathName /F=filters refNum as fileName
fileName = S_fileName // S_fileName is set by Open/D
if (strlen(fileName) == 0) // User cancelled?
return -2
endif
endif
// Load row 1 into numeric waves
XLLoadWave/S=worksheetName/R=($startCell,$endCell)/COLT="N"/O/V=0/K=0/Q fileName
if (V_flag == 0)
return -1 // User cancelled
endif
String names = S_waveNames // S_waveNames is created by XLLoadWave
String nameOut = UniqueName("Matrix", 1, 0)
Concatenate /KILL /O names, $nameOut // Create matrix and kill 1D waves
Printf "Created numeric matrix wave %s containing cells %s to %s in worksheet \"%s\"\r", nameOut, startCell, endCell, worksheetName
return 0 // Success
End
String pathName // Name of Igor symbolic path or "" to get dialog
String fileName // Name of file to load or "" to get dialog
String worksheetName
String startCell // e.g., "B1"
String endCell // e.g., "J100"
if ((strlen(pathName)==0) || (strlen(fileName)==0))
// Display dialog looking for file.
Variable refNum
String filters = "Excel Files (*.xls,*.xlsx,*.xlsm):.xls,.xlsx,.xlsm;"
filters += "All Files:.*;"
Open/D/R/P=$pathName /F=filters refNum as fileName
fileName = S_fileName // S_fileName is set by Open/D
if (strlen(fileName) == 0) // User cancelled?
return -2
endif
endif
// Load row 1 into numeric waves
XLLoadWave/S=worksheetName/R=($startCell,$endCell)/COLT="N"/O/V=0/K=0/Q fileName
if (V_flag == 0)
return -1 // User cancelled
endif
String names = S_waveNames // S_waveNames is created by XLLoadWave
String nameOut = UniqueName("Matrix", 1, 0)
Concatenate /KILL /O names, $nameOut // Create matrix and kill 1D waves
Printf "Created numeric matrix wave %s containing cells %s to %s in worksheet \"%s\"\r", nameOut, startCell, endCell, worksheetName
return 0 // Success
End
![](/sites/default/files/forum.png)
Forum
![](/sites/default/files/support.png)
Support
![](/sites/default/files/gallery.png)
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More