FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse: Error exporting to excel with ctod('')
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
XBrowse: Error exporting to excel with ctod('')
Posted: Tue Apr 23, 2013 09:22 AM
Hi guys,
Could anyone confirm whether this happen to you too.

Compile the test code below using Harbour. Run it and click the Excel button.

Code (fw): Select all Collapse
#include "fivewin.ch"
function main()
  local a_ := {ctod("")}

  xbrowse(a_)
return nil


It gave me this error,


I was using BCC5.82 + Harbour 3.2.0 + FWH11.8.

TIA.
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBrowse: Error exporting to excel with ctod('')
Posted: Tue Apr 23, 2013 10:33 AM
Thanks for pointing out the problem with assigning empty dates to excel cells in Harbour,
This works with xHarbour and can be used in date formulas.
( Note: The empty date value as exported to excel is different from clipper empty date for computational purposes. Ole dates start from 00-jan-1900)

For now please make this modification.
The original code near the error is :
Code (fw): Select all Collapse
         if ValType( uVal ) $ 'DT'
            if ! Empty( uVal ) .and. Year( uVal ) < 1900
               uVal  := DToC( uVal )
            endif
         endif
         oSheet:Cells( nRow, nCol ):Value := uVal   // Error in this line

You may replace this code with :
Code (fw): Select all Collapse
         if ValType( uVal ) $ 'DT'
            if ! Empty( uVal ) .and. Year( uVal ) < 1900
               uVal  := DToC( uVal )
            endif
#ifndef __XHARBOUR__
            if Empty( uVal )
               uVal  := 0
            endif
#endif
         endif
         oSheet:Cells( nRow, nCol ):Value := uVal

The exported value can still be used in formulas
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: XBrowse: Error exporting to excel with ctod('')
Posted: Thu Apr 25, 2013 03:24 AM

Thanks for the prompt fix Rao :)

I modified my xBrowse source to not post the date into Excel's cell if it's an empty date.

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion