Load Excel File To Powerbuilder

I have this code for buttonclicked event to load excel and text file to powerbuilder and the excel data is not copied i.e ll_return_xls <= 0 and thus when i want to load it to db i will get error since it has no value or data in it...The problem here is i get the data from text file but not from the excel file...Any help will be appreciated

    long    ll_return
    long    ll_return_xls
   OLEObject  excel 

   IF rb_file.checked then
  IF dwo.Name = "b_browse_meters"   THEN // Browse Button Clicked for Text

ll_return = GetFileOpenName ( "Select Meter File", is_fullname, is_filename, "TXT", &
    "Text Files (*.txt), *.txt" )

if ll_return < 1 then 
    gnv_msg.f_mensaje("EX28", "", "", OK!)
end if

  END IF // Browse Button Clicked

   IF dwo.Name ="b_browse_meters_xls" THEN // Browse Button Clicked for Excel

ll_return_xls = GetFileOpenName ( "Select Meter File", is_fullname, is_filename, "XLS", &
    "Excel Files (*.xls), *.xls" )

if ll_return_xls < 1 then 
    gnv_msg.f_mensaje("EX28", "", "", OK!)
end if

excel = create oleobject
    excel.ConnectToNewObject( "excel.application" )
excel.visible = false
excel.workbooks.open( is_fullname)
Destroy excel

END IF // Browse Button Clicked

And Function to load it the text and excel data

long    ll_return, ll_arr_len, ll_loop, ll_indx, ll_pass = 0
integer     li_rc, li_file_nbr, li_fr_rc //File Read Return Code
string      ls_file, ls_line, ls_msg
string lsa_meters[], lsa_meter_pass[]
string ls_meters
long    ll_total_valid, ll_total_aparatos

if IsValid(w_progbar) then Close(w_progbar)
openwithparm(w_progbar,"Uploading file data ...")

li_rc = SUCCESS
ll_total_aparatos = 0
ll_total_valid = 0

// Open file
if li_rc = SUCCESS then
ls_file = is_fullname
li_file_nbr = FileOpen(ls_file, LineMode!)
if IsNull(li_file_nbr) or li_file_nbr < 1 then
    li_rc = NO_ACTION
end if
end if

// Read file, store serial numbers into array lsa_meters[]
if li_rc = SUCCESS then // File Opened
ll_indx = 0
do while ll_indx > -1 and li_rc = SUCCESS
    li_fr_rc = FileRead(li_file_nbr, ls_line)
    choose case li_fr_rc
        case is > 0
            ll_indx ++
        lsa_meters[ll_indx] = ls_line
        case 0, -100
            ll_indx = -1
        case -1
            li_rc = FAILURE
            gnv_msg.f_mensaje("EX21", "", "", OK!)
        end choose

if li_rc = SUCCESS then // File Read OK
    ll_arr_len = UpperBound(lsa_meters)

    if ll_arr_len > 0 then // Data found in file
        for ll_loop = 1 to ll_arr_len step 1
            if ib_meter then
                ll_return = wf_luhn_check(lsa_meters[ll_loop])
                ll_total_valid ++
                if Len(lsa_meters[ll_loop]) >= 9 then
                    ll_return = 1
                    ll_total_valid ++
                    ll_return = -1
                end if
            end if
            if ll_return = 1 then
                if wf_aparatos_check(lsa_meters[ll_loop]) <= 0 then
                    ll_return = 1
                    ll_return = -1
                    ll_total_aparatos ++
                end if
            end if
            if ll_return = 1 then
                lsa_meter_pass[ll_pass] = lsa_meters[ll_loop]
                ls_meters = ls_meters + lsa_meters[ll_loop] + isk_TAB_PB
            end if
            w_progbar.uo_progress_bar.set_position(50 + ((ll_loop / ll_arr_len) * 40))

        ll_arr_len = UpperBound(lsa_meter_pass)

        if ll_arr_len > 0 then
            dw_datos_ingreso.Object.num_ini[1] = lsa_meter_pass[1]
            dw_datos_ingreso.Object.num_fin[1] = lsa_meter_pass[ll_arr_len]

            is_meters_passed = ls_meters // Concatenated string of meter serial no.
            il_apa_filemeters_count = ll_arr_len // Number of meters
            li_rc = FAILURE
            if ib_meter then
                gnv_msg.f_mensaje("EX27", "", "", OK!)
                gnv_msg.f_mensaje("EX22", "", "", OK!)
            end if
            if ll_total_valid = ll_total_aparatos then
                gnv_msg.f_mensaje("EX23", "", "", OK!)
            end if
        end if
        li_rc = FAILURE
        gnv_msg.f_mensaje("EX24", "", "", OK!)
    end if // Data found in file
end if // File Read OK
end if // File Opened


//Clean up
if li_file_nbr > 0 then
if FileClose(li_file_nbr) = FAILURE then
    li_rc = FAILURE
    gnv_msg.f_mensaje("EX25", "", "", OK!)
end if
 end if

 if ll_total_aparatos > 0 then
gnv_msg.f_mensaje("EW140", String(ll_total_aparatos) , "", OK!)
 end if

 if li_rc = FAILURE then
gnv_msg.f_mensaje("EX26", "", "", OK!)
  end if



You can use the ODBC driver directly to the Excel file, and then build a Pipeline object that moves the data from the spreadsheet directly into the database. Don't write code you don't need to.

Need Your Help

Changing image src with jQuery

jquery dom image

I'm replacing some code in an old application, and instead of getting the node by it's id I get it by it's class. Because there isn't a good way to get a node by it's class in native JS I do it with

Symfony2 not load Type when createForm

symfony2 symfony-2.1

I want createForm but symfony not load my top form:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.