identification division.
program-id. leo-excel.
*Raul E. Ramirez [email]rramirez@mendoza.gov.ar[/email]
*Nota Siempre cerrar el excel desde Archivo Salir
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
copy "..\def\excel.def".
DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ACHEQUE ASSIGN DISK
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
lock mode is automatic
record key is KEY-CHE
FILE STATUS IS FS-CHE.
DATA DIVISION.
FILE SECTION.
fd ACHEQUE label record standard
record 77 characters
value of file-id "cheque.dat"
data record REG-CHE.
01 REG-CHE.
02 KEY-CHE.
03 nro-che PIC 9(10).
02 nom-che PIC x(50).
02 imp-che PIC 9(15)v99.
WORKING-STORAGE SECTION.
*----------------------------------------------------------------*
77 FS-CHE pic xx value spaces.
78 newline value X"0A".
*----------------------------------------------------------------*
77 HexcelApp usage is handle of Application.
77 Hoja1 usage is handle of Worksheet.
77 HexcelWkb usage is handle of Workbook.
77 Hrange usage is handle of Range.
*----------------------------------------------------------------*
77 i pic 9(15).
77 j pic 99.
77 k pic 9999.
77 g pic 9(15).
*----------------------------------------------------------------*
01 coordenada.
02 letra pic xx.
02 numero pic 999999.
*----------------------------------------------------------------*
01 ColRow.
02 wcol.
03 wcol-l pic xx value spaces.
03 wcol-n pic 9(05) value 0.
03 filler pic x value ":".
03 wrow-l pic xx value spaces.
03 wrow-n pic 9(05) value 0.
*----------------------------------------------------------------*
01 wreg-che.
02 wnro-che PIC 9(10).
02 wnom-che PIC x(50).
02 wimp-che PIC 9(15)v99.
PROCEDURE DIVISION.
Inicio.
*----------------------------------------------------------------*
open OUTPUT ACHEQUE.
CLOSE ACHEQUE.
OPEN I-O ACHEQUE.
*----------------------------------------------------------------*
*Creo Aplicacion de Excel
Create @Application of @Excel Handle is HexcelApp.
*----------------------------------------------------------------*
*Busco planilla de excel
modify HexcelApp
Application::Workbooks
::Open "D:\clientes\pruebas\ej-act\excel\objetos\CHEQUE.xls".
*----------------------------------------------------------------*
inquire HexcelApp application::ActiveWorkbook in HexcelWkb.
inquire HexcelApp application::ActiveSheet in hoja1.
*----------------------------------------------------------------*
inquire hoja1 columns::item(1) in hrange.
*----------------------------------------------------------------*
modify HexcelApp application::Visible = 0.
*----------------------------------------------------------------*
move 1 to I
move 0 to G.
*----------------------------------------------------------------*
CARGA.
add 1 to I.
if I > 5 go F-CARGA.
display I AT 1010.
display G AT 1210.
*----------------------------------------------------------------*
*Capturo datos de la celda --> A
move " A" to letra.
move i to numero.
inquire hoja1 range(coordenada)::value wnro-che.
move wnro-che TO nro-che.
*----------------------------------------------------------------*
*Capturo datos de la celda --> B (Nombre)
move " B" to letra.
move i to numero.
inquire hoja1 range(coordenada)::value wnom-che.
move wnom-che TO nom-che.
*----------------------------------------------------------------*
*Capturo datos de la celda --> C (Importe)
move " C" to letra.
move i to numero.
inquire hoja1 range(coordenada)::value wimp-che.
move wimp-che TO imp-che.
*----------------------------------------------------------------*
write REG-CHE invalid
display message box " " newline
"Error - write " newline newline go carga.
*----------------------------------------------------------------*
add 1 to g.
GO CARGA.
*----------------------------------------------------------------*
F-CARGA.
*----------------------------------------------------------------*
close ACHEQUE.
modify HexcelApp application::Visible = 1.
*----------------------------------------------------------------*
display message box "Registros Grabados " g newline.
*----------------------------------------------------------------*
destroy hoja1.
* modify hexcelwkb @close(0).
destroy HexcelWkb.
* modify hexcelapp @quit().
destroy HexcelApp.
*----------------------------------------------------------------*
stop run.
Marcadores