Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Large Excel Files Slow down.
Message
De
14/03/2002 11:39:49
 
 
À
14/03/2002 10:02:16
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00632677
Message ID:
00632815
Vues:
11
Tom,

FYI. I changed a little code and it sped it up enormously. My guess it had to do with me using the loRange.COLUMNS[1].Value statement. Thanks again for the input.
LPARAMETERS tcWorkSheet

*--INT-MPL-03-13-2002...: Create a cursor
CREATE CURSOR IMPORT_FILE ( ;
  ADJUSTER_NAME	C(35),;
  CLAIM_PREFIX	C(10),;
  CLAIM_BODY	C(15),;
  CLAIM_SUFFIX	C(10),;
  CLAIM_NAME	C(40),;
  LOCATION		C(10),;
  SSN			C(9),;
  DOI			C(8),;
  STATE			C(2),;
  CAUSE			C(4),;
  BODY_PART		C(4),;
  DESCRIPTION	C(100),;
  CLAIM_STATUS	C(10))

*--INT-MPL-03-13-2002...: Create an Excel Object
loExcel = CREATEOBJECT('Excel.Application')
*--INT-MPL-03-13-2002...: Open the Workbook
loWorkBook = loExcel.Workbooks.OPEN(tcWorkSheet)

*--INT-MPL-03-13-2002...: Begin scanning through the work sheet.
LOCAL lcAdjusterName
lcAdjusterName = ''
lcRow = '1'
DO WHILE ALLTRIM(loExcel.Range('A'+lcRow).VALUE) # 'Grand Totals:' && check for end of report.
  WAIT WINDOW NOWAIT NOCLEAR lcRow && display row
  DO CASE
    CASE LEFT(ALLTRIM(loexcel.Range('A'+lcRow).VALUE),14) = 'Examiner Id #:' && title line for adjuster
      lcAdjusterName = ALLTRIM(UPPER(SUBSTR(ALLTRIM(loexcel.Range('A'+lcRow).VALUE),AT('-',ALLTRIM(loexcel.Range('A'+lcRow).VALUE))+1)))
    CASE ALLTRIM(loexcel.Range('D'+lcRow).VALUE) = '/' && claim row, Insert into cursor
      INSERT INTO IMPORT_FILE VALUES(;
        lcAdjusterName,;
        ALLTRIM(loexcel.Range('C'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('E'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('G'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('H'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('I'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('J'+lcRow).VALUE),;
        DTOS(loexcel.Range('K'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('L'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('M'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('N'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('O'+lcRow).VALUE),;
        ALLTRIM(loexcel.Range('P'+lcRow).VALUE))
  ENDCASE
  lcRow = ALLTRIM(STR(VAL(lcRow)+1))
ENDDO

WAIT CLEAR
*--INT-MPL-03-14-2002...: Exit the Excel application
loExcel.QUIT()
RELEASE ALL
>Have you considered saving the Excel file as a DBF and then doing an APPEND FROM into VFP?
>
>>Hello all,
>>
>>I am in need of some automation assistance. I have a program that reads an Excel file( generated by a reporting system) and loads the data into a cursor. The problem that I am having is that when I start the program it scans through the rows in Excel rather quickly but as the process goes on (around row 600) it takes almost a second to read each row. The files that I will be processing in a production environment are approximately 6000 rows. Can anyone see where I could speed this process up?
>>
>>
>>LPARAMETERS tcWorkSheet
>>
>>*--INT-MPL-03-13-2002...: Create a cursor
>>CREATE CURSOR IMPORT_FILE ( ;
>>	ADJUSTER_NAME	C(35),;
>>	CLAIM_PREFIX		C(10),;
>>	CLAIM_BODY		C(15),;
>>	CLAIM_SUFFIX		C(10),;
>>	CLAIM_NAME		C(40),;
>>	LOCATION			C(10),;
>>	SSN					C(9),;
>>	DOI					C(8),;
>>	STATE				C(2),;
>>	CAUSE				C(4),;
>>	BODY_PART			C(4),;
>>	DESCRIPTION		C(100),;
>>	CLAIM_STATUS		C(10))
>>
>>*--INT-MPL-03-13-2002...: Create an Excel Object
>>loExcel = CREATEOBJECT('Excel.Application')
>>*--INT-MPL-03-13-2002...: Open the Workbook
>>loWorkBook = loExcel.Workbooks.OPEN(tcWorkSheet)
>>
>>*--INT-MPL-03-13-2002...: Begin scanning through the work sheet.
>>LOCAL lcAdjusterName
>>lcAdjusterName = ''
>>loRange = loExcel.ActiveSheet.RANGE("A1:P1")
>>DO WHILE ALLTRIM(loRange.COLUMNS[1].VALUE) # 'Grand Totals:' && check for end of report.
>>	WAIT WINDOW NOWAIT NOCLEAR ALLTRIM(STR(loRange.ROW)) && display row
>>	DO CASE
>>		CASE LEFT(ALLTRIM(loRange.COLUMNS[1].VALUE),14) = 'Examiner Id #:' && title line for adjuster
>>			lcAdjusterName =ALLTRIM(UPPER(SUBSTR(ALLTRIM(loRange.COLUMNS[1].VALUE),AT('-',ALLTRIM(loRange.COLUMNS[1].VALUE))+1)))
>>		CASE ALLTRIM(loRange.COLUMNS[4].VALUE) = '/' && claim row, Insert into cursor
>>			INSERT INTO IMPORT_FILE VALUES(;
>>				lcAdjusterName,;
>>				ALLTRIM(loRange.COLUMNS[3].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[5].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[7].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[8].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[9].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[10].VALUE),;
>>				DTOS(loRange.COLUMNS[11].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[12].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[13].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[14].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[15].VALUE),;
>>				ALLTRIM(loRange.COLUMNS[16].VALUE))
>>	ENDCASE
>>	loRange = loRange.OFFSET(1,0) && move down one row
>>ENDDO
>>WAIT CLEAR
>>*--INT-MPL-03-14-2002...: Exit the Excel application
>>loExcel.QUIT()
>>RELEASE ALL
>>
>>
>>Matt
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform