Comment appliquer un style ou formater l'ensemble des cellules

Bonjour,

Je cherche à centrer l’ensemble des cellules d’un tableur pour une page nouvellement créée.

J’ai vu (mais pas enregistré) qu’on pouvait le faire en appliquant un style.

Sinon il y a HoriJustify et VertJustify qui s’appliquent sur une cell.

Voici (un extrait) de mon code (la matice à imprimer vient d’une autre section):

 Sub Gene_Output(Mat_Tonal() as integer, MajMin as boolean)
 
 	dim oBoock as object
 	dim oSheets as object
 	dim oSheet as object
 	dim oRange as object
 	dim oCell as object
 	dim sSheet as string
 	dim sRange as string
 	dim sCell as string
 	
 	dim I as integer, J as Integer, K as Integer
 	
 	sSheet = "Résultats"
 	
 	oBoock = ThisComponent
 	oSheets = oBoock.Sheets
 	
 	'Création de la feuile de sortie
 
 	If oSheets.hasByName(sSheet) Then
  		oSheet = oSheets.getByName(sSheet)
 	Else
 		oSheet = oBoock.createInstance("com.sun.star.sheet.Spreadsheet")
 		oSheets.insertByName(sSheet, oSheet)
 	End If
 
 	'impose la largeur des colonnes
 	with oSheet.columns()
 		.width = 1000
 	end with
 	with oSheet.Rows()
 		.Height = 500
 	end with
 	' centrer les cellules vert et horiz (ou en appliquant le stype "Centree" qui existe dans le tableur)
 '	oSheet.getCellByPosition(5,5).HoriJustifY = com.sun.star.table.CellHoriJustify.CENTER
 	with oSheet.getCellByPosition()
 		.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER		
 		.VertJustify = com.sun.star.table.CellVertJustify.CENTER
 	end with
 	
 		
 end sub

Ou alors ‘With … End With’ ne fonctionne qu’avec 1 argument?

Merci pour votre réponse.

J’ai bien trouvé une réponse partielle:

 	iNumCol = 30
 	iNumLin = 90
 	For I = 0 to iNomCol - 1
 		For J = 0 to iNumLin - 1
 			with oSheet.getCellByposition(I,J)
 				.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER		
 				.VertJustify = com.sun.star.table.CellVertJustify.CENTER
 				.string = ""
 			end with
 		next
 	next

Mais comment alors trouver le nombre Max de colonnes et de Lignes?

Merci