>>.NumberFormat = "###,###,###" >>* Or condtional formatting >>.NumberFormat = "#[=0];###,###,###.00" >>>>
>function DBFToExcel >lparameters tcXLSFileName, taHeader_Info >* This function assumes, that the output table (cursor) is currently opened >*-- Generate output to XLS File > >local loExcel, lnI, loSheet, lnK, lcTempFile, lcError >*lcTempFile = addbs(sys(2023)) + "TempXLS" + sys(3) + ".XLS" >lcError = "" > >#define xlShiftDown -4121 >#define xlShiftToLeft -4159 >#define xlShiftToRight -4161 >#define xlShiftUp -4162 > >* Line styles >#Define xlContinuous 1 >#Define xlDash -4115 >#Define xlDashDot 4 >#Define xlDashDotDot 5 >#Define xlDot -4118 >#Define xlDouble -4119 >#Define xlSlantDashDot 13 >#Define xlLineStyleNone -4142 > >* Weight >#Define xlHairline 1 >#Define xlMedium -4138 >#Define xlThick 4 >#Define xlThin 2 > >*-- Add Header into XLS File >try > copy to (m.tcXLSFileName) TYPE XL5 >*-- Create Ole Automation with Excel > loExcel=createobject("Excel.Application") >*-- Open XLS File > loExcel.application.WorkBooks.open(m.tcXLSFileName) > for lnI = 1 to loExcel.application.application.WorkBooks(1).Sheets.count >*-- Select individual sheet from open XLS File > loSheet = loExcel.application.application.WorkBooks(1).Sheets(m.lnI) >* loSheet.select > >** Delete the column headers from Excel (first row) > loSheet.rows("1").delete(xlShiftDown) > loSheet.rows("1:3").insert(xlShiftDown) > > With loSheet.Range("1:2").Font > * .Color = Rgb(255,0,0) > .Size = 11 > .Bold = .T. > .Name = 'Tahoma' > Endwith > >*!* With loSheet.Range("1:2").Borders >*!* .Weight = xlMedium >*!* .LineStyle = xlContinuous >*!* Endwith > > for lnK = 1 to alen(taHeader_Info,1) > loSheet.Cells(1,m.lnK).value = taHeader_Info[m.lnK,1] > loSheet.Cells(2,m.lnK).value = taHeader_Info[m.lnK,2] > > if !empty(taHeader_Info[m.lnK,3]) && There is format information > *loSheet.columns[m.lnK].select > loSheet.columns[m.lnK].NumberFormat = taHeader_Info[m.lnK,3] > endif > if !empty(taHeader_Info[m.lnK,4]) && There is Column Width > loSheet.columns[m.lnK].select > loSheet.columns[m.lnK].ColumnWidth = taHeader_Info[m.lnK,4] > endif > next > next > loExcel.application.WorkBooks(1).save() > >catch to loError > lcError = Log_Error(m.loError) >finally > if vartype(m.loExcel) = 'O' > loExcel.quit > endif >endtry >if not empty(m.lcError) > =ErrorMsg(m.lcError) >endif >return m.lcError >endfunc >loRange = loSheet.UsedRange.Offset(3,0)