Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Export to Excel, Date field problem
Message
 
 
To
23/02/2007 07:52:05
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
DB2
Miscellaneous
Thread ID:
01198209
Message ID:
01198260
Views:
9
This message has been marked as the solution to the initial question of the thread.
>You may set date column NumberFormat to 'dd/mm/yyyy'
>
>Where should I use NumberFormat to 'dd/mm/yyyy' in my procedure?
set safety off
use ?
als1=alias()
if !empty(als1)
local lnI, lnDCol
local array laCols[1,2], laFields[1]
=afields(laFields)
lnDCol = 0
for lnI = 1 to alen(laFields,1)
     do case
        case laFields[m.lnI,2] = 'D' && date
            lnDCol = m.lnDCol + 1
            dimension laCols[m.lnDCol,2]
            laCols[m.lnDCol,1] = m.lnI
            laCols[m.lnDCol,2] = 'mm/dd/yyyy'
        case laFields[m.lnI,2] = 'T' && datetime
             lnDCol = m.lnDCol + 1
            dimension laCols[m.lnDCol,2]
            laCols[m.lnDCol,1] = m.lnI
            laCols[m.lnDCol,2] = 'mm/dd/yyyy hh:mm:ss'
        endcase
next
	gcdelimname =alias() + '.xls'
	gcdelimfile = putfile('excel_file:', gcdelimname, 'xls')
	if !empty(gcdelimfile)
		copy to (gcdelimfile) type xl5 && Create Excel
	endif

	res=messagebox("Do you want to Open " + gcDelimName,4+32+512,"Dbf2Xls")
	if res=6
		loexcel = createobject("Excel.Application")
		loworkbook = loexcel.workbooks.open(gcdelimfile)
		losheet = loworkbook.sheets(1) 
                  for lnI = 1 to alen(laDCols,1)
                      loSheet.Columns(laDCols[m.lnI,1]).NumberFormat = laDCols[m.lnI,2]
                  next
              	losheet.columns().autofit() 
		loexcel.visible = .t. && display Excel
	endif
endif
Something like this, from the top of my head and not tested.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform