Help with Excel.

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
luisvasquezcl
Posts: 1263
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Help with Excel.

Post by luisvasquezcl »

Hello friends,
I wonder if there is any basis to let me know how many columns
and rows are occupied by data in an Excel spreadsheet.
Thanks in advance for your answers.
Best regards,
Luis Vasquez

Hola amigos,
quisiera saber si hay alguna función que me permita saber cuantas columnas
y filas hay ocupadas por datos en una hoja de Excel.
Gracias anticipadas por sus respuestas.
Muchas gracias.
LUis Vasquez.
User avatar
millipede
Posts: 10
Joined: Thu May 14, 2009 7:36 am
Location: Mexico DF
Contact:

Re: Help with Excel.

Post by millipede »

Hola, parece que esto necesitas. saludos.

Function excel_things()
Local oExcel, oSheet
Local nRows_op1, nRows_op2
Local nCols_op1, nCols_op2

oExcel:= CreateObject("Excel.Application")
oExcel:Visible:= .N.
oExcel:DisplayAlerts:= .N.
oExcel:Workbooks:Open("Test.xls", .Y.) // open ReadOnly
oExcel:Sheets(1):select()
oSheet:= oExcel:ActiveSheet()

nRows_op1:= oExcel:Sheets(1):UsedRange:Rows:Count()
nRows_op2:= oSheet:UsedRange:Rows:Count()

nCols_op1:= oExcel:Sheets(1):UsedRange:Columns:Count()
nCols_op2:= oSheet:UsedRange:Columns:Count()

msgInfo( str(nRows_op1)+str(nRows_op2), "rows")
msgInfo( str(nCols_op1)+str(nCols_op2), "cols")

oExcel:application:Quit() // excel off
return nil
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Help with Excel.

Post by mol »

Nice function!
THX for sharing!
Best regards ,Marek
User avatar
luisvasquezcl
Posts: 1263
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: Help with Excel.

Post by luisvasquezcl »

Excelente Millipede, muchas gracias por tu rápida respuesta, me sacaste de un buen problema ... tremendo aporte.
Saludos cordiales,
Luis Vasquez.
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Help with Excel.

Post by Rathinagiri »

Nice utility. Thanks a lot.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply