Delphi to Excel һЩ·½·¨
Ò») ʹÓö¯Ì¬´´½¨µÄ·½·¨
Ê×ÏÈ´´½¨ Excel ¶ÔÏó£¬Ê¹ÓÃComObj:
var ExcelApp: Variant;
ExcelApp := CreateOleObject( 'Excel.Application' );
1) ÏÔʾµ±Ç°´°¿Ú£º
ExcelApp.Visible := True;
2) ¸ü¸Ä Excel ±êÌâÀ¸£º
ExcelApp.Caption := 'Ó¦ÓóÌÐòµ÷Óà Microsoft Excel';
3) Ìí¼Óй¤×÷²¾£º
ExcelApp.WorkBooks.Add;
4) ´ò¿ªÒÑ´æÔڵŤ×÷²¾£º
ExcelApp.WorkBooks.Open( 'C:\Excel\Demo.xls' );
5) ÉèÖõÚ2¸ö¹¤×÷±íΪ»î¶¯¹¤×÷±í£º
ExcelApp.WorkSheets[2].Activate;
»ò
ExcelApp.WorksSheets[ 'Sheet2' ].Activate;
6) ¸øµ¥Ôª¸ñ¸³Öµ£º
ExcelApp.Cells[1,4].Value := 'µÚÒ»ÐеÚËÄÁÐ';
7) ÉèÖÃÖ¸¶¨ÁеĿí¶È£¨µ¥Î»£º×Ö·û¸öÊý£©£¬ÒÔµÚÒ»ÁÐΪÀý£º
ExcelApp.ActiveSheet.Columns[1].ColumnsWidth := 5;
8) ÉèÖÃÖ¸¶¨Ðеĸ߶ȣ¨µ¥Î»£º°õ£©£¨1°õ£½0.035ÀåÃ×£©£¬ÒÔµÚ¶þÐÐΪÀý£º
ExcelApp.ActiveSheet.Rows[2].RowHeight := 1/0.035; // 1ÀåÃ×
9) ÔÚµÚ8ÐÐ֮ǰ²åÈë·ÖÒ³·û£º
ExcelApp.WorkSheets[1].Rows.PageBreak := 1;
10) ÔÚµÚ8ÁÐ֮ǰɾ³ý·ÖÒ³·û£º
ExcelApp.ActiveSheet.Columns[4].PageBreak := &
Ïà¹ØÎĵµ£º
1.Round£¨ËÄÉáÁùÈëÎåÁôË«£©
¹¦ÄÜ˵Ã÷£º¶ÔÒ»¸öʵÊý½øÐÐËÄÉáÎåÈë¡£(°´ÕÕÒøÐмÒËã·¨)
Àý£º
var
i, j: Integer;
begin
i := Round(1.5); // iµÈÓÚ2
j := Round(2.5); // jµÈÓÚ2
end;
ÔÚDelphiÖÐʹÓÃRoundº¯ÊýµÃµ½µÄ´ð°¸ÓÐʱÓëÎÒÃÇËùÔ¤ÆÚµÄ»á²»Ì«Ò»Ñù£º²ÉÓõÄÊÇËÄÉáÁùÈëÎåÁôË«¡£¼´µ±Éá»òÈëλ´óÓÚ»òСÓÚÎåÊ ......
//¶¨ÒåÈ«¾Ö±äÁ¿
public
{ Public declarations }
outlook,MailItem,Recipient:variant;
OutlookNameSpace:variant;
OutlookFolder:variant;
OutlookAttachment:variant;
//´´½¨´ò¿ªoutlook
procedure TForm1.CreateOutLook;
begin
try
outlook:=CreateOleObject('OutLook.app ......
Ò»¡¢Formatº¯ÊýµÄÓ÷¨
FormatÊÇÒ»¸öºÜ³£Óã¬È´ÓÖËÆºõºÜ·³µÄ·½·¨£¬±¾ÈËÊÔͼ¶ÔÕâ¸ö·½·¨µÄ°ïÖú½øÐÐһЩ·Ò룬ÈÃËüÓÐÒ»¸öÍêÕûµÄ¸Åò£¬ÒÔ¹©´ó¼Ò²éѯ֮Óãº
Ê×ÏÈ¿´ËüµÄÉùÃ÷£º
function Format(const Format: string; const Args: array of const): string; overload;
ÊÂʵÉÏFormat·½·¨ÓÐÁ½¸öÖÖÐÎʽ£¬ÁíÍâÒ»ÖÖÊÇÈý¸ö²ÎÊýµÄ£¬Ö ......
function ListFiles(Dir: String):TStrings;
var
FSearchRec: TSearchRec;
FileList: TStrings;
FindResult: Integer;
begin
if Dir[length(Dir)]<>'\' then Dir:=Dir+'\';
FileList :=TStringList.Create;
FindResult:=FindFirst(Dir+'*.*,faAnyFile+faDirectory,FSearchRec);
while FindRes ......
Èý²ã¼Ü¹¹Ö¸µÄÊǽçÃæ£¬ÒµÎñÂß¼ºÍÊý¾Ý´æ´¢·ÖÀë,²»ÊÇÖ¸ÎïÀíÉÏÊÇ·ñ·ÖÀë¡£
ÕâÑù×öµÄºÃ´¦ÊDzã´Î·ÖÃ÷£¬Î¬»¤ºÃ×ö£¬ÏµÍ³×ÊÔ´Ò²ºÃ·Ö²¼Ê½´¦Àí¡£
Êý¾Ý¿â²ãÄľͲ»ËµÁË£¬ÓÃMSSQL¡¢OrcaleËæÄãÁË£¬¾ÍÊÇÊý¾Ý·þÎñ²ã
ÒµÎñÂß¼µÄ»°Òª·ÖÎöÇå³þ£¬¾ÍÊÇÖмä²ã
½çÃæ£¬Ò²½Ð¿Í»§¶Ë¡£ÕâÀï¾ÍÊǵõ½Êý¾ÝºÍÏÔʾÊý¾ÝµÄ²¿·ÖÁË£¬²»×öÆäËü´¦Àí¡£µ«ÊÇÊý¾ÝÓÐ ......