//Exceldatei einfärben
procedure TMAin.Xls_To_Color(AXLSFile: string; Zeile : integer; Farbe : string; Text : integer);
const
xlCellTypeLastCell = $0000000B;
var
Excel, Sheet: OLEVariant;
Puffer : string;
Color : integer;
begin
deletefile('C:\Users\' + login + '\Documents\RESUME.XLW');
if farbe = 'Weiß' then Color := 0;
if farbe = 'Rot' then Color := 3;
if farbe = 'Grün' then Color := 10;
if farbe = 'Blau' then Color := 41;
if farbe = 'Gelb' then Color := 6;
// Create Excel-
OLE Object
Excel := CreateOleObject('Excel.Application');
try
// Hide Excel
Excel.Visible := False;
// Open the Workbook
Excel.Workbooks.Open(AXLSFile);
// Sheet := XLApp.Workbooks[1].WorkSheets[1];
Sheet := Excel.Workbooks[ExtractFileName(AXLSFile)].WorkSheets[1];
Puffer := inttostr(Zeile+1)+':'+inttostr(Zeile+1);
Excel.Range[Puffer].Select;
if text = 1 then Excel.Selection.Font.colorindex := Color else Excel.Selection.Interior.ColorIndex := Color;
// Oberste Zeile Fett und Grau
Excel.Range[inttostr(1)+':'+inttostr(1)].Select;
Excel.Selection.Font.FontStyle := 'Bold';
Excel.Selection.Interior.ColorIndex := 15 ;
//Rahmen zeichnen
Excel.Range['A1:' + 'AZ' + inttostr(Display.RowCount - 1)].select;
//Excel.Selection.Borders[xlEdgeLeft].LineStyle := xlContinuous;
finally
// Save file and Quit Excel
if not VarIsEmpty(Excel) then
begin
Excel.save;
Excel.Quit;
Excel := Unassigned;
Sheet := Unassigned;
end;
end;
end;