Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Spreadsheet update
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00317983
Message ID:
00360919
Vues:
8
How are you reading the contents of the spreadsheet into FoxPro? Are you processing one row at a time, or are you reading in all
the row data and then processing it? If you are reading in all the row data in a single pass, perhaps you are running out of working
space, such as an array not being properly dimensioned. What sort of errors are you seeing, if any?

However, you did say that Excel is hanging. Are you positive that it is Excel that's hanging? Could you send me a sample of how
you are setting up the connection, and how you are accessing and updating the Excel cells?

Talk to you later!

Michael Reynolds

First I launch excel and get the object reference . . .

WITH This
* Test to see if an object already exists, If not - do it
*
lcSessType = VARTYPE( .r_oXlsSess )
IF lcSessType <> 'O'
.r_oXlsSess = CREATEOBJECT( 'Excel.Application' )
ENDIF

* Open the file, then get a reference to the First Worksheet
*
.r_oXlsSess.WorkBooks.Open( lcFileName )
.r_oXlsSheet= .r_oXlsSess.ActiveWorkBook.ActiveSheet

* Go to the upper left corner, then the bottom of the first column
* and get the last Cell (row/col) reference
*
.r_oXlsSess.Range("A1").Select
.r_oXlsSess.Selection.End( -4121 ).Select
.r_nRowTotl = .r_oXlsSess.Selection.Row


* Go to the upper left corner,
* Go to the right on this row till:
* a) last cell with data or,
* b) next cell with data
* and get the last Cell (row/col) reference
*
.r_oXlsSess.Range("A1").Select
.r_oXlsSess.Selection.End( 2 ).Select
.r_nColTotl = .r_oXlsSess.Selection.Column

IF VARTYPE( .r_aStruAray[ 1, 1 ] ) = 'C'
.r_nColTotl = ALEN( .r_aStruAray, 1 )
ELSE
l_Colhdg = .m_GetSrcDta( 1 )
IF VARTYPE( l_ColHdg ) = 'C'
.r_lValidateColName = .F.
.r_nStrtRow = 2
ENDIF
ENDIF
.r_lHeadIngs= ( .r_nStrtRow = 2 )

ENDWITH

Then, by iterating through the identified matrix limits ( .r_oXlsSess.RowTotl, .r_oXlsSess.ColTotl ), I capture the
data in each cell to a memvar.

l_RetVal = .r_oXlsSheet.Cells( .r_nRowId, .r_nColId ).Value

The contents are placed into a memvar in preparation for an INSERT into my
target table. Prior to the INSERT, the memvar value is massaged and manipulated
based upon business rules.

I have confirmed that it is the excel server that is hanging. When I end task
the server, foxpro can nolonger access the object, and returns an error stating so:

Member CELLS does not evaluate to an object.

Foxpro then can continue, or rather exit after error.

Using the original excel file works fine, 6004 rows, 10 columns.
Copying columns 2-10 to positions 11-19 causes the above mentioned problem.

The "fry-point" is after processing 3470 rows, on row 3470, at least 3 cells have successfully processed,
(on the last run).

Frankly, I'm stumped.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform