Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

selecting excel sheet thru fortran

shailendra_singh
Beginner
276 Views
I saw few messages in the forum which indicates that some of us are struggling to select different sheet in excel workbook when they use fortran code to do that. I too was working on it and found a way to do it.....
NSHEET = $Worksheet_GetIndex(worksheet, status)
DO N = 2,NSHEET
worksheet = $Worksheet_GetPrevious(worksheet, status)
ENDDO
DO N = 1,100
sheet = $Worksheet_GetName(worksheet, STATUS)
IF(SHEET .EQ. SHEET1)GOTO 10
worksheet = $Worksheet_GetNext(worksheet, status)
ENDDO
10 continue
the first line will return the active sheet index. one has to reach at first sheet to start search, and that's exactly happening thru first loop. Once you got the first sheet, start comparing the name of the sheet with predefined sheet1(character*(*) sheet1) and once u got it, come out of the loop.
I tried it in my code and it's working fine.....
let me know if any one need further explanation.......i am also able to set and get environment variable to access excel workbook and so i need not to hard code the entire path(remember legacy AUTODICE code)....i just mentioned it so that one can get info if needed...
thanks to all group member.
:smileyhappy:
0 Kudos
0 Replies
Reply