Hello,
I am reading an Excel Sheet as follows:
oRange := GetExcelRange( ExePath() + "test.xls" )
@ 0,0 XBROWSE oBrw OF oWnd AUTOCOLS ;
DATASOURCE oRange CELL LINES FOOTERS ;
SIZES 80, 80, 80, 80
How can I get Excel´s header names?.
Thanks.
retrieve excel headers
retrieve excel headers
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: retrieve excel headers
If you know the first row of the range contains headers, you can extract them
oHead := oRange:Rows( 1 )
oHead is a single row object representing the first row of oRange.
May I know what is your exact requirement?
oHead := oRange:Rows( 1 )
oHead is a single row object representing the first row of oRange.
May I know what is your exact requirement?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: retrieve excel headers
Mr. Rao,
Thanks for reply.
I want to xBrowse an Excel and I want to set Excel headers in xBrowse.
This is my code:
Thanks for reply.
I want to xBrowse an Excel and I want to set Excel headers in xBrowse.
This is my code:
Code: Select all
#include "fivewin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw, oBar, oFont, n
local oRange, u
local oSheet
local nRow, nCol, nRows, nCols, xValue
local cHeaders := { "A", "B", "C" }
local nSizes := { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140 }
SET DATE ITALIAN
SET CENTURY ON
//fwNumFormat( 'E', .t. )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE WINDOW oWnd TITLE "XBrowse Excel Sheet"
oWnd:SetFont( oFont )
DEFINE BUTTONBAR oBar OF oWnd 2007
SET MESSAGE OF oWnd TO '' 2007
oRange := GetExcelRange( ExePath() + "test.xls" )
oSheet := oRange:WorkSheet
nRows := oSheet:UsedRange:Rows:Count()
nCols := oSheet:UsedRange:Columns:Count()
For nRow := 1 TO nRows
FOR nCol := 1 TO nCols
xValue := oSheet:Cells(nRow,nCol):Value
if xValue = nil
oSheet:Cells(nRow,nCol):Value := (" ") // replace nil with space
endif
Next
Next I
@ 0,0 XBROWSE oBrw OF oWnd AUTOCOLS ;
DATASOURCE oRange CELL LINES FOOTERS ;
HEADERS cHeaders ;
SIZES nSizes
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd MAXIMIZED
RELEASE FONT oFont
oRange:WorkSheet:Parent:Close(.F.) // Not save changes
return nil
function ExePath()
return cFilePath( GetModuleFileName() )
FWH 11.11, Harbour 3.1 and Borland C++ 5.82