Page 1 of 1

XBrowsing Excel Data

PostPosted: Thu Aug 11, 2011 3:09 pm
by nageswaragunupudi
XBrowse, supported by FWH function GetExelRange() simplifies browsing Data in Excel files.

Here is a sample worksheet.
Image

Assuming the Excel file is saved as "xbrtest.xls" ( can be xlsx extention too), here is a small sample to browse the data.
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

function Main()

   local oWnd, oBrw, oBar, oFont
   local oRange,  u

   SET DATE ITALIAN
   SET CENTURY ON

   fwNumFormat( 'E', .t. )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
   DEFINE WINDOW oWnd TITLE "XBrowse Excel Sheet: FWH 11.07"
   oWnd:SetFont( oFont )
   DEFINE BUTTONBAR oBar OF oWnd 2007
   SET MESSAGE OF oWnd TO '' 2007

   oRange   := GetExcelRange( ExePath() + "xbrtest.xls", "Customers", "A1:E12" )
   @ 0,0 XBROWSE oBrw OF oWnd AUTOCOLS ;
      PICTURES nil, nil, nil, 'dd-mmm-yyyy', NumPict( 12,2 ) ;
      DATASOURCE oRange CELL LINES FOOTERS

   oBrw:Sales:bFooter   := { || oRange:Application:WorkSheetFunction:Sum(oRange:Columns(5)) }
   oBrw:nStretchCol     := 1
   oBrw:CreateFromCode()
   oWnd:oClient   := oBrw

   ACTIVATE WINDOW oWnd
   RELEASE FONT oFont
   oRange:WorkSheet:Parent:Close()

return nil

function ExePath()
return cFilePath( GetModuleFileName() )
 

XBrowse screenshot:
Image

Re: XBrowsing Excel Data

PostPosted: Thu Aug 11, 2011 3:47 pm
by gkuhnert
Rao,

this is a great sample. Maybe we should ask Antonio to enclose the sample together with your Excel-file in the samples-folder for the next build!