Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel Sheet Formatting
Message
 
 
À
16/01/2006 10:50:02
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01087027
Message ID:
01101759
Vues:
15
>Borislav, Tariq,
>Thanks to Sergey, you can surpres 0s this way
>
>.NumberFormat = "###,###,###"
>* Or condtional formatting
>.NumberFormat = "#[=0];###,###,###.00"
>
>

How can I apply this format to the range, e.g. I don't want the format to be applied to the first 3 rows where I put my column titles. Here is my current code:
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
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform