Author | Topic: leer datos desde un planilla excel. | |
---|---|---|
Gustavo M. Burgos | leer datos desde un planilla excel. on Thu, 14 Jun 2012 11:40:24 -0300 hola todos. el tema es que debo leer uno productos que vienen un planilla excel. y volcarlos a una bases de datos con algunos ejemplo logro sin problema de enviar desde un dbf a excel. si alguien tiene algo desde ya muy agradecido.- Gustavo M. Burgos Rivadavia 278 Pcia Roque Saenz Peña - Chaco Argentina Burmanspm@arnet.com.ar Fijo 0364-4420634 Movil 364-4408559 | |
Jorge L | Re: leer datos desde un planilla excel. on Thu, 14 Jun 2012 13:13:15 -0300 Gustavo, leer una planilla excel es muy fácil, con el ejemplo que trae alaska en activex te alcanza For G :=1 To nTotElem If ( aCel[G] > 0 ) aLect[G] :=oBook:ActiveSheet:Cells( i, aCel[G] ):value EndIF Next G particularmente para detectar el fin de archivo , me aseguro leer 50 filas vacias si necesitas el ejemplo mas amplio me avisas "Gustavo M. Burgos" escribió en el mensaje de noticias:6389d520$5d55246f$2d3b@news.alaska-software.com... hola todos. el tema es que debo leer uno productos que vienen un planilla excel. y volcarlos a una bases de datos con algunos ejemplo logro sin problema de enviar desde un dbf a excel. si alguien tiene algo desde ya muy agradecido.- Gustavo M. Burgos Rivadavia 278 Pcia Roque Saenz Peña - Chaco Argentina Burmanspm@arnet.com.ar Fijo 0364-4420634 Movil 364-4408559 | |
Pablo Botella Navarro | Re: leer datos desde un planilla excel. on Thu, 14 Jun 2012 18:42:52 +0200 Hola, Como dice Jorge para cosas sueltas con el ejemplo que trae Xbase++ te sobra. Si los ficheros son grandes o son muchos igual te interesaría una funcioncita que le hice a un cliente de UK xls2array( cXls ) ( le salió por unos 150 EUR ), la diferencia es la velocidad ahi estoy usando IDispatch con ot4xb directamente en lugar del soporte ActiveX de Alaska Si te interesa me escribes. Saludos, Pablo | |
Gustavo M. Burgos | Re: leer datos desde un planilla excel. on Thu, 14 Jun 2012 16:28:16 -0300 gracia Jorge necesitaba un poco de orientación al respecto pablo gracias por la oferta la tendré en cuenta, veré primero si con esto puedo solucionar el problema si no me estoy comunicando contigo. un saludo Gustavo M. Burgos Rivadavia 278 Pcia Roque Saenz Peña - Chaco Argentina Burmanspm@arnet.com.ar Fijo 0364-4420634 Movil 364-4408559 "Jorge L" <jlborlando@way.com.ar> escribió en el mensaje de noticias:738a5b47$19b8204d$2dcd@news.alaska-software.com... > Gustavo, leer una planilla excel es muy fácil, con el ejemplo que trae > alaska en activex te alcanza > > For G :=1 To nTotElem > If ( aCel[G] > 0 ) > aLect[G] :=oBook:ActiveSheet:Cells( i, aCel[G] ):value > EndIF > Next G > > > particularmente para detectar el fin de archivo , me aseguro leer 50 filas > vacias > > si necesitas el ejemplo mas amplio me avisas > > "Gustavo M. Burgos" escribió en el mensaje de > noticias:6389d520$5d55246f$2d3b@news.alaska-software.com... > > hola todos. el tema es que debo leer uno productos que vienen un planilla > excel. y volcarlos a una bases de datos > con algunos ejemplo logro sin problema de enviar desde un dbf a excel. si > alguien tiene algo desde ya muy agradecido.- > > > -- > Gustavo M. Burgos > Rivadavia 278 > Pcia Roque Saenz Peña - Chaco > Argentina > Burmanspm@arnet.com.ar > Fijo 0364-4420634 > Movil 364-4408559 > | |
AUGE_ OHR | Re: leer datos desde un planilla excel. on Fri, 15 Jun 2012 00:40:12 +0200 hi, > For G :=1 To nTotElem > If ( aCel[G] > 0 ) > aLect[G] :=oBook:ActiveSheet:Cells( i, aCel[G] ):value > EndIF > Next G you do not need a "loop" to "read" ( or "write" ) just make a Array "same size" like your XLS like this does NOT work ??? oSheet:Select oSheet:usedRange:Select but this work oWorkBook:workSheets(1):usedRange:Select Number Row / Col numRows := oWorkBook:workSheets(1):usedRange:Rows:Count numColumns := oWorkBook:workSheets(1):usedRange:Columns:Count make Array same Size FOR i := 1 TO numRows AADD(aExcel,ARRAY(numColumns)) NEXT Excel use A1 ... find last Cell cEnde := ZAHL2CHR(numColumns) now pass hole select range to you Array -> 1 Sec aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value Quit Excel oExcel:Quit() RETURN aExcel if you have a big XLS be sure to have much RAM ( XP 3GB -> up to 1.5GB ) greetings by OHR Jimmy FUNCTION ZAHL2CHR(numColumns) LOCAL nMal LOCAL cEnde IF numColumns > 26 nMal := INT(numColumns/26) cEnde := CHR(nMal+64)+CHR((numColumns-(nMal*26))+64) ELSE cEnde := CHR(numColumns+64) ENDIF RETURN cEnde | |
Jorge L | Re: leer datos desde un planilla excel. on Fri, 15 Jun 2012 17:06:04 -0300 thanks Jimmy i have a question and a problem when i execute oexcel:quit(), excel don't remove from memory, you have a same problem ? "AUGE_ OHR" escribió en el mensaje de noticias:291affef$fb9376c$54d8@news.alaska-software.com... hi, > For G :=1 To nTotElem > If ( aCel[G] > 0 ) > aLect[G] :=oBook:ActiveSheet:Cells( i, aCel[G] ):value > EndIF > Next G you do not need a "loop" to "read" ( or "write" ) just make a Array "same size" like your XLS like this does NOT work ??? oSheet:Select oSheet:usedRange:Select but this work oWorkBook:workSheets(1):usedRange:Select Number Row / Col numRows := oWorkBook:workSheets(1):usedRange:Rows:Count numColumns := oWorkBook:workSheets(1):usedRange:Columns:Count make Array same Size FOR i := 1 TO numRows AADD(aExcel,ARRAY(numColumns)) NEXT Excel use A1 ... find last Cell cEnde := ZAHL2CHR(numColumns) now pass hole select range to you Array -> 1 Sec aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value Quit Excel oExcel:Quit() RETURN aExcel if you have a big XLS be sure to have much RAM ( XP 3GB -> up to 1.5GB ) greetings by OHR Jimmy FUNCTION ZAHL2CHR(numColumns) LOCAL nMal LOCAL cEnde IF numColumns > 26 nMal := INT(numColumns/26) cEnde := CHR(nMal+64)+CHR((numColumns-(nMal*26))+64) ELSE cEnde := CHR(numColumns+64) ENDIF RETURN cEnde | |
AUGE_ OHR | Re: leer datos desde un planilla excel. on Fri, 15 Jun 2012 23:50:15 +0200 hi, >when i execute oexcel:quit(), excel don't remove from memory, you have a >same problem ? which Excel / Office Version ? older like 2002/2003 seem to have the Problem did you have "close" your Sheet before oExcel:quit() ? greetings by OHR Jimmy | |
Jorge L | Re: leer datos desde un planilla excel. on Sat, 16 Jun 2012 09:55:20 -0300 hi Jimmy, i have de same problem with all versions , 2010 included i open the sheet.... oXls :=CreateObject( "Excel.Application" ) oBook := oXls:workbooks:Open( ConvToOEMCP( cName2 ) ) oSheet := oBook:ActiveSheet i close the sheet oSheet:Destroy() add without change nothing oBook:Close() oBook:Destroy() add without change nothing oXls:Quit() oXls:Destroy() add without change nothing regards "AUGE_ OHR" escribió en el mensaje de noticias:49911866$4fb26e10$8a3e@news.alaska-software.com... hi, >when i execute oexcel:quit(), excel don't remove from memory, you have a >same problem ? which Excel / Office Version ? older like 2002/2003 seem to have the Problem did you have "close" your Sheet before oExcel:quit() ? greetings by OHR Jimmy | |
Jos Luis Otermin | Re: leer datos desde un planilla excel. on Tue, 21 Aug 2012 14:16:48 -0300 Hello Jorge In order to make things easier and cleaner, you have to keep in mind you needed to :create() new instances of many objects and it is not right just simply abandon them in memory with the only invocation to :close() or :quit() methods. You have to follow a golden rule: 1-instantiate 2-create 3-manipulate ... 4-close the interface 5-destroy the instance 6-destroy the variable which references to the instance. To manipulate entire external programs with foreign interfaces you have to respect a given order: oObject:close() closes the opened window oObject:quit() quits the object instance oObject := NIL calls the immediate action of garbage collector. HTH Saludos Jos Luis Otermin "Jorge L" <jlborlando@way.com.ar> escribi en el mensaje news:2fea72c4$51b3b2be$61f6@news.alaska-software.com... > thanks Jimmy > > i have a question and a problem > > when i execute oexcel:quit(), excel don't remove from memory, you have a > same problem ? > > > "AUGE_ OHR" escribi en el mensaje de > noticias:291affef$fb9376c$54d8@news.alaska-software.com... > > hi, > >> For G :=1 To nTotElem >> If ( aCel[G] > 0 ) >> aLect[G] :=oBook:ActiveSheet:Cells( i, >> aCel[G] ):value >> EndIF >> Next G > > you do not need a "loop" to "read" ( or "write" ) > just make a Array "same size" like your XLS like this > > > does NOT work ??? > oSheet:Select > oSheet:usedRange:Select > > but this work > oWorkBook:workSheets(1):usedRange:Select > > Number Row / Col > numRows := oWorkBook:workSheets(1):usedRange:Rows:Count > numColumns := oWorkBook:workSheets(1):usedRange:Columns:Count > > make Array same Size > FOR i := 1 TO numRows > AADD(aExcel,ARRAY(numColumns)) > NEXT > > Excel use A1 ... find last Cell > cEnde := ZAHL2CHR(numColumns) > > now pass hole select range to you Array -> 1 Sec > aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value > > Quit Excel > oExcel:Quit() > > RETURN aExcel > > if you have a big XLS be sure to have much RAM ( XP 3GB -> up to 1.5GB ) > > greetings by OHR > Jimmy > > FUNCTION ZAHL2CHR(numColumns) > LOCAL nMal > LOCAL cEnde > IF numColumns > 26 > nMal := INT(numColumns/26) > cEnde := CHR(nMal+64)+CHR((numColumns-(nMal*26))+64) > ELSE > cEnde := CHR(numColumns+64) > ENDIF > RETURN cEnde > > | |
Jorge L | Re: leer datos desde un planilla excel. on Tue, 21 Aug 2012 22:06:18 -0300 Don José, una alegría volver a verlo por estos lugares nuevamente voy a preparar un ejemplo clásico y espero que haya manera de resolverlo en vez de matarlo saludos "José Luis Otermin" escribió en el mensaje de noticias:5d932873$2ff22e6b$9b17@news.alaska-software.com... Hello Jorge In order to make things easier and cleaner, you have to keep in mind you needed to :create() new instances of many objects and it is not right just simply abandon them in memory with the only invocation to :close() or :quit() methods. You have to follow a golden rule: 1-instantiate 2-create 3-manipulate ... 4-close the interface 5-destroy the instance 6-destroy the variable which references to the instance. To manipulate entire external programs with foreign interfaces you have to respect a given order: oObject:close() closes the opened window oObject:quit() quits the object instance oObject := NIL calls the immediate action of garbage collector. HTH Saludos José Luis Otermin "Jorge L" <jlborlando@way.com.ar> escribió en el mensaje news:2fea72c4$51b3b2be$61f6@news.alaska-software.com... > thanks Jimmy > > i have a question and a problem > > when i execute oexcel:quit(), excel don't remove from memory, you have a > same problem ? > > > "AUGE_ OHR" escribió en el mensaje de > noticias:291affef$fb9376c$54d8@news.alaska-software.com... > > hi, > >> For G :=1 To nTotElem >> If ( aCel[G] > 0 ) >> aLect[G] :=oBook:ActiveSheet:Cells( i, >> aCel[G] ):value >> EndIF >> Next G > > you do not need a "loop" to "read" ( or "write" ) > just make a Array "same size" like your XLS like this > > > does NOT work ??? > oSheet:Select > oSheet:usedRange:Select > > but this work > oWorkBook:workSheets(1):usedRange:Select > > Number Row / Col > numRows := oWorkBook:workSheets(1):usedRange:Rows:Count > numColumns := oWorkBook:workSheets(1):usedRange:Columns:Count > > make Array same Size > FOR i := 1 TO numRows > AADD(aExcel,ARRAY(numColumns)) > NEXT > > Excel use A1 ... find last Cell > cEnde := ZAHL2CHR(numColumns) > > now pass hole select range to you Array -> 1 Sec > aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value > > Quit Excel > oExcel:Quit() > > RETURN aExcel > > if you have a big XLS be sure to have much RAM ( XP 3GB -> up to 1.5GB ) > > greetings by OHR > Jimmy > > FUNCTION ZAHL2CHR(numColumns) > LOCAL nMal > LOCAL cEnde > IF numColumns > 26 > nMal := INT(numColumns/26) > cEnde := CHR(nMal+64)+CHR((numColumns-(nMal*26))+64) > ELSE > cEnde := CHR(numColumns+64) > ENDIF > RETURN cEnde > > | |
Jos Luis Otermin | Re: leer datos desde un planilla excel. on Wed, 22 Aug 2012 01:55:13 -0300 Jelou Don Jorge! Hay vicios que no se pierden. Se entendi que hay que "matar" la variable que contiene la referencia al objeto externo pero antes hay que ordenarle que se cierren las ventanas y se cierre el programa? Un abrazo Jose "Jorge L" <jlborlando@way.com.ar> escribi en el mensaje news:3c1a7092$70a08ed5$959f@news.alaska-software.com... > Don Jos, una alegra volver a verlo por estos lugares nuevamente > > voy a preparar un ejemplo clsico y espero que haya manera de resolverlo > en vez de matarlo > > > saludos > > "Jos Luis Otermin" escribi en el mensaje de > noticias:5d932873$2ff22e6b$9b17@news.alaska-software.com... > > Hello Jorge > > In order to make things easier and cleaner, you have to keep in mind you > needed to :create() new instances of many objects and it is not right just > simply abandon them in memory with the only invocation to :close() or > :quit() methods. You have to follow a golden rule: > 1-instantiate > 2-create > 3-manipulate > ... > 4-close the interface > 5-destroy the instance > 6-destroy the variable which references to the instance. > > To manipulate entire external programs with foreign interfaces you have to > respect a given order: > oObject:close() closes the opened window > oObject:quit() quits the object instance > oObject := NIL calls the immediate action of garbage collector. > > HTH > > Saludos > > Jos Luis Otermin > > > > "Jorge L" <jlborlando@way.com.ar> escribi en el mensaje > news:2fea72c4$51b3b2be$61f6@news.alaska-software.com... >> thanks Jimmy >> >> i have a question and a problem >> >> when i execute oexcel:quit(), excel don't remove from memory, you have a >> same problem ? >> >> >> "AUGE_ OHR" escribi en el mensaje de >> noticias:291affef$fb9376c$54d8@news.alaska-software.com... >> >> hi, >> >>> For G :=1 To nTotElem >>> If ( aCel[G] > 0 ) >>> aLect[G] :=oBook:ActiveSheet:Cells( i, >>> aCel[G] ):value >>> EndIF >>> Next G >> >> you do not need a "loop" to "read" ( or "write" ) >> just make a Array "same size" like your XLS like this >> >> >> does NOT work ??? >> oSheet:Select >> oSheet:usedRange:Select >> >> but this work >> oWorkBook:workSheets(1):usedRange:Select >> >> Number Row / Col >> numRows := oWorkBook:workSheets(1):usedRange:Rows:Count >> numColumns := oWorkBook:workSheets(1):usedRange:Columns:Count >> >> make Array same Size >> FOR i := 1 TO numRows >> AADD(aExcel,ARRAY(numColumns)) >> NEXT >> >> Excel use A1 ... find last Cell >> cEnde := ZAHL2CHR(numColumns) >> >> now pass hole select range to you Array -> 1 Sec >> aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value >> >> Quit Excel >> oExcel:Quit() >> >> RETURN aExcel >> >> if you have a big XLS be sure to have much RAM ( XP 3GB -> up to 1.5GB ) >> >> greetings by OHR >> Jimmy >> >> FUNCTION ZAHL2CHR(numColumns) >> LOCAL nMal >> LOCAL cEnde >> IF numColumns > 26 >> nMal := INT(numColumns/26) >> cEnde := CHR(nMal+64)+CHR((numColumns-(nMal*26))+64) >> ELSE >> cEnde := CHR(numColumns+64) >> ENDIF >> RETURN cEnde >> >> > | |
Gustavo M. Burgos | Re: leer datos desde un planilla excel. on Thu, 06 Sep 2012 17:53:30 -0300 Gracia Por el aporte, solucione el problema saludos cordiales Gustavo Mohamed Burgos Burmanspm@arnet.com.ar Rivadavia 278 Pcia Roque Saenz Peña - CHACO Argentina Fijo 0364-4420635 Movil 0364-4-408559 "José Luis Otermin" escribió en el mensaje de noticias:59cf4cbf$465e5fed$94e7@news.alaska-software.com... Jelou Don Jorge! Hay vicios que no se pierden. ¿Se entendió que hay que "matar" la variable que contiene la referencia al objeto externo pero antes hay que ordenarle que se cierren las ventanas y se cierre el programa? Un abrazo Jose "Jorge L" <jlborlando@way.com.ar> escribió en el mensaje news:3c1a7092$70a08ed5$959f@news.alaska-software.com... > Don José, una alegría volver a verlo por estos lugares nuevamente > > voy a preparar un ejemplo clásico y espero que haya manera de resolverlo > en vez de matarlo > > > saludos > > "José Luis Otermin" escribió en el mensaje de > noticias:5d932873$2ff22e6b$9b17@news.alaska-software.com... > > Hello Jorge > > In order to make things easier and cleaner, you have to keep in mind you > needed to :create() new instances of many objects and it is not right just > simply abandon them in memory with the only invocation to :close() or > :quit() methods. You have to follow a golden rule: > 1-instantiate > 2-create > 3-manipulate > ... > 4-close the interface > 5-destroy the instance > 6-destroy the variable which references to the instance. > > To manipulate entire external programs with foreign interfaces you have to > respect a given order: > oObject:close() closes the opened window > oObject:quit() quits the object instance > oObject := NIL calls the immediate action of garbage collector. > > HTH > > Saludos > > José Luis Otermin > > > > "Jorge L" <jlborlando@way.com.ar> escribió en el mensaje > news:2fea72c4$51b3b2be$61f6@news.alaska-software.com... >> thanks Jimmy >> >> i have a question and a problem >> >> when i execute oexcel:quit(), excel don't remove from memory, you have a >> same problem ? >> >> >> "AUGE_ OHR" escribió en el mensaje de >> noticias:291affef$fb9376c$54d8@news.alaska-software.com... >> >> hi, >> >>> For G :=1 To nTotElem >>> If ( aCel[G] > 0 ) >>> aLect[G] :=oBook:ActiveSheet:Cells( i, >>> aCel[G] ):value >>> EndIF >>> Next G >> >> you do not need a "loop" to "read" ( or "write" ) >> just make a Array "same size" like your XLS like this >> >> >> does NOT work ??? >> oSheet:Select >> oSheet:usedRange:Select >> >> but this work >> oWorkBook:workSheets(1):usedRange:Select >> >> Number Row / Col >> numRows := oWorkBook:workSheets(1):usedRange:Rows:Count >> numColumns := oWorkBook:workSheets(1):usedRange:Columns:Count >> >> make Array same Size >> FOR i := 1 TO numRows >> AADD(aExcel,ARRAY(numColumns)) >> NEXT >> >> Excel use A1 ... find last Cell >> cEnde := ZAHL2CHR(numColumns) >> >> now pass hole select range to you Array -> 1 Sec >> aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value >> >> Quit Excel >> oExcel:Quit() >> >> RETURN aExcel >> >> if you have a big XLS be sure to have much RAM ( XP 3GB -> up to 1.5GB ) >> >> greetings by OHR >> Jimmy >> >> FUNCTION ZAHL2CHR(numColumns) >> LOCAL nMal >> LOCAL cEnde >> IF numColumns > 26 >> nMal := INT(numColumns/26) >> cEnde := CHR(nMal+64)+CHR((numColumns-(nMal*26))+64) >> ELSE >> cEnde := CHR(numColumns+64) >> ENDIF >> RETURN cEnde >> >> > |