- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody,
I was wondering if anyone know how to add a new excel worksheet to the existing EXCEL workbook using the intel visual fortran.
Thanks
I was wondering if anyone know how to add a new excel worksheet to the existing EXCEL workbook using the intel visual fortran.
Thanks
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is some sample code:
[bash]! Create an Excel object; excelapp = Excel_Create () !CALL COMCREATEOBJECT ("Excel.Application", excelapp, status) IF (excelapp == 0) RETURN CALL $Application_SetVisible (excelapp, TRUE2) CALL $Application_SetScreenUpdating (excelapp, FALSE2) ! Get the WORKBOOKS object workbooks = $Application_GetWorkbooks (excelapp, $STATUS = status) IF (status /= 0) RETURN ! Open a new spreadsheet from the template file workbook = Workbooks_Open (workbooks, tbuf, $STATUS = status) IF (status /= 0) RETURN ! Get the worksheet worksheet = $Workbook_GetActiveSheet (workbook, status) IF (status /= 0) RETURN ! Newer Excel versions require different activition strings, ! according to Intel's AutoDice example ! Excel.Application Excel 2000 and before ! Excel.Application.11 Excel 2003 ! Excel.Application.12 Excel 2007 ! Excel.Application.13 Excel 2010 INTEGER(INT_PTR_KIND()) FUNCTION Excel_Create INTEGER(INT_PTR_KIND()) :: exapp INTEGER :: j CHARACTER(LEN=20) :: appstring = "Excel.Application." CALL COMCREATEOBJECT (appstring(1:17), exapp, status) IF (exapp == 0) THEN ! load fails DO j = 13, 11, -1 WRITE (appstring(19:20), '(I2)') j CALL COMCREATEOBJECT (appstring, excelapp, status) IF (exapp /= 0) EXIT END DO END IF Excel_Create = exapp END FUNCTION Excel_Create[/bash]
[bash]! Create an Excel object; excelapp = Excel_Create () !CALL COMCREATEOBJECT ("Excel.Application", excelapp, status) IF (excelapp == 0) RETURN CALL $Application_SetVisible (excelapp, TRUE2) CALL $Application_SetScreenUpdating (excelapp, FALSE2) ! Get the WORKBOOKS object workbooks = $Application_GetWorkbooks (excelapp, $STATUS = status) IF (status /= 0) RETURN ! Open a new spreadsheet from the template file workbook = Workbooks_Open (workbooks, tbuf, $STATUS = status) IF (status /= 0) RETURN ! Get the worksheet worksheet = $Workbook_GetActiveSheet (workbook, status) IF (status /= 0) RETURN ! Newer Excel versions require different activition strings, ! according to Intel's AutoDice example ! Excel.Application Excel 2000 and before ! Excel.Application.11 Excel 2003 ! Excel.Application.12 Excel 2007 ! Excel.Application.13 Excel 2010 INTEGER(INT_PTR_KIND()) FUNCTION Excel_Create INTEGER(INT_PTR_KIND()) :: exapp INTEGER :: j CHARACTER(LEN=20) :: appstring = "Excel.Application." CALL COMCREATEOBJECT (appstring(1:17), exapp, status) IF (exapp == 0) THEN ! load fails DO j = 13, 11, -1 WRITE (appstring(19:20), '(I2)') j CALL COMCREATEOBJECT (appstring, excelapp, status) IF (exapp /= 0) EXIT END DO END IF Excel_Create = exapp END FUNCTION Excel_Create[/bash]

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page