WhiteHippo
Messages postés1154Date d'inscriptionsamedi 14 août 2004StatutMembreDernière intervention 5 avril 20123 12 juil. 2007 à 17:48
Bonsoir,
Voici un extrait de code utilisé pour le formatage d'une plage de cellules d'un tableau excel :
// Pour info, ewsFeuille1 est un TExcelWorksheet
// _LigDebut, _ColDebut, _LigFin , _ColFin sont des entiers à définir en fonction des besoins
// _CaractereGras est un booléen pour formatter ou non les caractères en gras
// _Fusion est un booléen pour fusionner ou non les cellules de la plage
Var
Etendue : ExcelRange ;
begin
Etendue := ewsFeuille1.Range
[
ewsFeuille1.Cells.Item[ _LigDebut, _ColDebut ],
ewsFeuille1.Cells.Item[ _LigFin , _ColFin ] ];
with Etendue do
begin
// Caractères gras
Font.Bold := _CaractereGras ;
// Formatage des bordures intérieures
if ( ( _LigFin - _LigDebut ) > 0 ) then
begin
with Borders.Item[ xlInsideHorizontal ] do
begin
LineStyle := xlContinuous ; Weight := xlThin ;
end ;
end ;
if ( ( _ColFin - _ColDebut ) > 0 ) then
begin
with Borders.Item[ xlInsideVertical ] do
begin
LineStyle := xlContinuous ; Weight := xlThin ;
end ;
end ;
with Borders.Item[ xlDiagonalDown ] do
begin
LineStyle := xlNone ;
end ;
with Borders.Item[ xlDiagonalUp ] do
begin
LineStyle := xlNone ;
end ;
// Formatage des bordures extérieures
with Borders.Item[ xlEdgeLeft ] do
begin
LineStyle := xlContinuous ;
Weight := xlMedium ;
ColorIndex := xlAutomatic ;
end ;
with Borders.Item[ xlEdgeTop ] do
begin
LineStyle := xlContinuous ;
Weight := xlMedium ;
ColorIndex := xlAutomatic ;
end ;
with Borders.Item[ xlEdgeBottom ] do
begin
LineStyle := xlContinuous ;
Weight := xlMedium ;
ColorIndex := xlAutomatic ;
end ;
with Borders.Item[ xlEdgeRight ] do
begin
LineStyle := xlContinuous ;
Weight := xlMedium ;
ColorIndex := xlAutomatic ;
end ;
end;
end;
Cordialement. <hr />"L'imagination est plus importante que le savoir." Albert Einstein