Excel - error al importar
Moderator: Rathinagiri
-
Mario Mansilla
- Posts: 270
- Joined: Wed Aug 13, 2008 2:35 pm
- Location: Córdoba - Argentina
Excel - error al importar
Hola Amigos :
les adjunto un pequeño proyecto para que puedan ayudarme a encontrar el problema que causa que a veces al importar la planilla excel me da los mensajes de error que muestra el archivo errorlog .
La planilla excel esta en la carpeta importacion , hacen click en la lupa y buscan la planilla y luego aceptar .
Desde ya muchas gracias
Saludos
Mario Rafael Mansilla
Hi friends :
I am attaching a small project so that you can help me find the problem that sometimes when importing the excel spreadsheet it gives me the error messages that the errorlog file shows.
The excel spreadsheet is in the import folder, click on the magnifying glass and look for the spreadsheet and then accept.
From already thank you very much
Greetings
Mario Rafael Mansilla
les adjunto un pequeño proyecto para que puedan ayudarme a encontrar el problema que causa que a veces al importar la planilla excel me da los mensajes de error que muestra el archivo errorlog .
La planilla excel esta en la carpeta importacion , hacen click en la lupa y buscan la planilla y luego aceptar .
Desde ya muchas gracias
Saludos
Mario Rafael Mansilla
Hi friends :
I am attaching a small project so that you can help me find the problem that sometimes when importing the excel spreadsheet it gives me the error messages that the errorlog file shows.
The excel spreadsheet is in the import folder, click on the magnifying glass and look for the spreadsheet and then accept.
From already thank you very much
Greetings
Mario Rafael Mansilla
- Attachments
-
- Excel.rar
- (2.33 MiB) Downloaded 200 times
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: Excel - error al importar
Hola Mario, lo puedes solucionar haciendo una copia de los datos a una nueva Hoja de Calculo, solo tienes que copiar los datos, sin cabecera ni ordenaciones. Por lo visto el problema viene dado por tener la hoja de calcula la cabecera fija.Mario Mansilla wrote: ↑Tue Dec 14, 2021 4:13 pm Hola Amigos :
les adjunto un pequeño proyecto para que puedan ayudarme a encontrar el problema que causa que a veces al importar la planilla excel me da los mensajes de error que muestra el archivo errorlog .
La planilla excel esta en la carpeta importacion , hacen click en la lupa y buscan la planilla y luego aceptar .
Desde ya muchas gracias
Saludos
Mario Rafael Mansilla
Hi friends :
I am attaching a small project so that you can help me find the problem that sometimes when importing the excel spreadsheet it gives me the error messages that the errorlog file shows.
The excel spreadsheet is in the import folder, click on the magnifying glass and look for the spreadsheet and then accept.
From already thank you very much
Greetings
Mario Rafael Mansilla
Con esto ya lo tienes.., salud y una cervecita fresquita.
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. 
- serge_girard
- Posts: 3342
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Excel - error al importar
I think there is an error in the sheet. Try to save it as CSV and then edit in your program editor.
There's nothing you can do that can't be done...
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: Excel - error al importar
Hola Serge, no creo que la hoja tenga errores, creo en mi humilde opinión que tiene por un lado algo de programación y tambien 3 páginas ocultas que tienen vinculación con la Excel principal...,serge_girard wrote: ↑Wed Dec 15, 2021 8:49 am I think there is an error in the sheet. Try to save it as CSV and then edit in your program editor.
Si por el contrario se copian los datos a una nueva hoja (cotar y pegar), el funcionamiento es correcto.
Igual alguien (y ahora que tenemos más datos), sabe como se prodria importar una hoja de estas caracteristicas sería estupendo.
Vamos con esa cervecita fresquita!!!
- Attachments
-
- excel1.JPG (9.84 KiB) Viewed 5394 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. 
- AUGE_OHR
- Posts: 2096
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: Excel - error al importar
hi,
this Code "crash" when want to "select" (in wrong Way)
try it this Way
now i have to ask : do you want to get hole Sheet
if yes
use nRow /nCol (convert to A-Z) to "select Range" and copy/paste it to Array with "same Size"
---
you also can "fill" a Excel Sheet this Way
this Code "crash" when want to "select" (in wrong Way)
Code: Select all
oExcel:WorkBooks:Open( cArchivo )
oExcel:Sheets(nHoja):Select() -> crash
// "Error WINOLE/1009 No exported method SHEETS Parameter : [ 1] = N 1 (DOS Error -2147418111)
oHoja := oExcel:ActiveSheet()
Code: Select all
oBook := oExcel:Workbooks:Open(cExcelFile)
oSheet := oBook:ActiveSheet
oRange := oSheet:usedRange
nCol := oRange:Columns:Count()
nRow := oRange:Rows:Count()
if yes
use nRow /nCol (convert to A-Z) to "select Range" and copy/paste it to Array with "same Size"
Code: Select all
aExcel := ARRAY(nRow,nCol)
cEnde := ZAHL2CHR(nCol)
// now "fill" Array from Sheet Range
aExcel := oSheet:range( "A1:"+cEnde+LTRIM( STR(nRow) ) ):value---
you also can "fill" a Excel Sheet this Way
Code: Select all
oSheet:range( "A1:"+cEnde+LTRIM( STR( nRow ) ) ) :value := aExcelhave fun
Jimmy
Jimmy
Re: Excel - error al importar
@Serge, SALINETAS24, Jimmy
It's not exactly what you suggest.
it is just that the workbook has not yet been fully loaded into Excel and therefore does not yet have sheet objects.
See a simple test:
@ Mario Mansilla
See this solution:
It's not exactly what you suggest.
it is just that the workbook has not yet been fully loaded into Excel and therefore does not yet have sheet objects.
See a simple test:
Code: Select all
...
nHoja := 1
oExcel:WorkBooks:Open( cArchivo )
Sleep ( 1000 )
oExcel:Sheets(nHoja):Select()
oHoja := oExcel:ActiveSheet()
...See this solution:
Code: Select all
...
nHoja := 1
oExcel:WorkBooks:Open( cArchivo )
// catch any errors
bErrBlck := ErrorBlock( { | oError | ExcelError( oError ) } )
lIsExcelFullyLoaded := .F.
DO WHILE .NOT. lIsExcelFullyLoaded
BEGIN SEQUENCE
nSheets := oExcel:Sheets:Count
lIsExcelFullyLoaded := .T.
RECOVER
lIsExcelFullyLoaded := .F.
END
ENDDO
//Restore the previous ErrorBlock
ErrorBlock( bErrBlck )
oExcel:Sheets(nHoja):Select()
oHoja := oExcel:ActiveSheet()
...
...
**************************************************************
FUNCTION ExcelError( oError )
BREAK oError
RETURN Nil
- AUGE_OHR
- Posts: 2096
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: Excel - error al importar
hi Edward,
you are right that is is a Problem of "timeing"
thats why i do use "single Step" to get oBook, oSheet and oRange to avoid "sleep"
you are right that is is a Problem of "timeing"
thats why i do use "single Step" to get oBook, oSheet and oRange to avoid "sleep"
have fun
Jimmy
Jimmy
Re: Excel - error al importar
I'm using xlsxclass to read data from Excel in one of my application. It's fast and no Excel is needed
- Rathinagiri
- Posts: 5481
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Excel - error al importar
Man! You are God sent!
edk wrote: ↑Wed Dec 15, 2021 2:17 pm @Serge, SALINETAS24, Jimmy
It's not exactly what you suggest.
it is just that the workbook has not yet been fully loaded into Excel and therefore does not yet have sheet objects.
See a simple test:@ Mario MansillaCode: Select all
... nHoja := 1 oExcel:WorkBooks:Open( cArchivo ) Sleep ( 1000 ) oExcel:Sheets(nHoja):Select() oHoja := oExcel:ActiveSheet() ...
See this solution:Code: Select all
... nHoja := 1 oExcel:WorkBooks:Open( cArchivo ) // catch any errors bErrBlck := ErrorBlock( { | oError | ExcelError( oError ) } ) lIsExcelFullyLoaded := .F. DO WHILE .NOT. lIsExcelFullyLoaded BEGIN SEQUENCE nSheets := oExcel:Sheets:Count lIsExcelFullyLoaded := .T. RECOVER lIsExcelFullyLoaded := .F. END ENDDO //Restore the previous ErrorBlock ErrorBlock( bErrBlck ) oExcel:Sheets(nHoja):Select() oHoja := oExcel:ActiveSheet() ... ... ************************************************************** FUNCTION ExcelError( oError ) BREAK oError RETURN Nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.