免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
delphi導(dǎo)出Excel
procedure Tfrm_main.XLGW_Excel(p_int_Row_Begin, p_int_Col_Begin,
  p_int_Row_End, p_int_Col_End: Integer; p_str_Value, p_str: String);
var
  m_Query : TADOQuery;
  m_StringList_FieldNames : TStringList;
  m_int,rowid : Integer;
  m_int_Row : Integer;
  ExcelApp,ExcelObj:TExcel;  //引用excel單元
  m_str,Astr : String;
  HJXLCD:string;
  i:Integer;  //用于控制列寬變量
begin
  m_Query := TADOQuery.Create(nil);
    ExcelObj:=TExcel.Create;
    try
      {填寫表頭}
      m_Query.Connection:= sqlclass.conn;
      m_str := p_str;
      m_Query.Close;
      m_Query.SQL.Clear;
      m_Query.SQL.Add(m_str);
      try
        m_Query.Open;
      except
        ShowMessage('報表輸出失敗,請重新計算!');
        Exit;
      end;
      if m_Query.IsEmpty then
      begin
        ShowMessage('沒有要導(dǎo)出的數(shù)據(jù)!');
        Exit;
      end;
      if not ExcelObj.New_WorkBook then    //顯示工作薄
      begin
        ShowMessage('新建工作簿失敗');
        Exit;
      end;
      try
      //頁面設(shè)置                       //縱向xlPortrait       //橫向xlLandscape
      ExcelObj.SetSheetPage(xlPaperA4,xlLandscape,0.6,0.6,0.6,0.6,0.3,0.3);
      except
      end;
      ExcelObj.IsVisible(True);  //控制是否顯示Excel
      m_StringList_FieldNames := TStringList.Create;
      m_Query.GetFieldNames(m_StringList_FieldNames);
      ExcelObj .SetCell('序號',2,1,0);
      for m_int := 1 to m_StringList_FieldNames.Count do
      begin
        //設(shè)置指定單元格的值
        ExcelObj.SetCell(m_StringList_FieldNames.Strings[m_int - 1],2, m_int+1,0);
      end;

    {寫入數(shù)據(jù)}
      rowid :=0;
      m_int_Row := 3;  //行
      while not  m_Query.Eof do
      begin
        rowid:=rowid+1;
        ExcelObj.SetCell(IntToStr(rowid),m_int_Row, 1,1); //加序號
        for m_int := 1 to m_StringList_FieldNames.Count do
        begin
          //判斷輸出字段類型
          //  (0:字符型;1:整形;2,3:數(shù)值型)  增加清零操作
          Astr:= m_Query.FieldByName(m_StringList_FieldNames.Strings[m_int - 1]).AsString;
         { if m_Query.Fields[m_int - 1].DataType in [ftSmallint, ftInteger,ftBCD ] then
          begin
            if (Astr = '') or (StrtoInt(Astr)=0) then
            begin
              Continue;
            end;
           //ExcelObj.SetCell(Astr,m_int_Row, m_int+1,1);    //weixing 20100707
          end
          else }
            if  m_Query.Fields[m_int - 1].DataType in [ftWord,ftFloat] then
            begin
                if (Astr = '') or (StrtoFloat(Astr)=0) then
                begin
                  Continue;
                end;
               ExcelObj.SetCell(Astr,m_int_Row, m_int+1,2);
            end
            else if m_Query.Fields[m_int - 1].DataType in [ftInteger] then  //weixing 20100707
            begin
                if (Astr = '') or (StrtoFloat(Astr)=0) then
                begin
                  Continue;
                end;
                ExcelObj.SetCell(Astr,m_int_Row, m_int+1,1);
            end
            else
            begin
              ExcelObj.SetCell(Astr,m_int_Row, m_int+1,0);
            end;//if
         end; //if
       // end;//for
        m_int_Row := m_int_Row + 1;
        m_Query.Next;
      end;//While
        for i:=1 to 13 do
        begin
          if (i=1) then
            ExcelObj.SetColumnWidth(i,24)
           else
            ExcelObj.SetColumnWidth(i,7);
         end;
      for m_int:=1 to m_int_Row-1 do
      begin
        ExcelObj.SetRowHeight(m_int,18); //設(shè)置指定行的行高
        //單元格居中
        ExcelObj.SetRowHorizontalAlignment(m_int,xlHAlignCenter);
        ExcelObj.SetRowVerticalAlignment(m_int,xlHAlignCenter);
      end;
      p_int_Col_End:=m_StringList_FieldNames.Count;
      {設(shè)置表格函數(shù)}
      ExcelObj.MergeCells(p_int_Row_Begin, p_int_Col_Begin,p_int_Row_End, p_int_Col_End);//合并單元格
      //設(shè)置標(biāo)題指定范圍的值
      ExcelObj.SetRangeValue(1,1,p_int_Row_Begin, p_int_Col_Begin,p_str_Value);
      //生成標(biāo)題參數(shù)設(shè)置
      ExcelObj.SetRowFontStyle(p_int_Row_Begin,'加粗','宋體',0,15);
      //標(biāo)題行高
      ExcelObj.SetRowHeight(1,33); //設(shè)置指定行的行高

      //加單元格
      ExcelObj.SetRangeOutBorderStyle(2,1,m_int_Row-1, m_StringList_FieldNames.Count+1,2,0,1);//單元格外部加邊線
      ExcelObj.SetRangeInnerLineStyle(2,1,m_int_Row-1, m_StringList_FieldNames.Count+1,2,0,1);//單元格內(nèi)部加邊線
      ExcelObj.SetRangeAutoWrap(3,1,3, m_StringList_FieldNames.Count);//指定行自動換行
      //ExcelObj.SetRowFontStyle(3,'加粗','宋體',0,12);//生成排頭參數(shù)設(shè)置
      //最后一行合計所有數(shù)值字段
      //ExcelObj.SetRangeValue(m_int_Row,1,m_int_Row,1,'合計'); //往單元格寫入'合計';
     { for m_int := 1 to m_StringList_FieldNames.Count do
        //行列號為: m_int_Row,m_int ;
      begin
        if m_Query.Fields[m_int - 1].DataType in [ftSmallint, ftInteger, ftWord,ftFloat,ftBCD] then
        begin
          HJXLCD:=FloatToStr(ExcelObj.Sum(4,m_int,m_int_Row,m_int)); //合計線路長度
          ExcelObj.SetRangeValue(m_int_Row,m_int,m_int_Row,m_int,HJXLCD);
        end;
      end; }
      ExcelObj.CellAutoFit;//自動列寬
      m_StringList_FieldNames.free;
   finally
      m_Query.Free;
      ExcelObj.Destroy;
   end;
end;


 

 

 

{利用OLE技術(shù)實現(xiàn)的與Excel應(yīng)用程序的接口
 可以實現(xiàn)表格設(shè)計,數(shù)據(jù)輸出,模板定制,
 打印設(shè)置,打印預(yù)覽,打印表格等功能;}

unit Excel_Unit;{單元名稱}

interface{接口部分}
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Excel97,OleServer, StdCtrls,Variants,ExcelConst_Unit,ComObj;
const

  //報表平面圖參數(shù)
  pm_Title = '配 電 線 路 條 圖';

  pm_PageRows = 21;

  pm_PageOffset = 530;//     //頁與頁之間圖形距離

  pm_LineLeft   = 123;       //線起始left
  pm_LineTop    = 72;//74;   //線起始top
  pm_LineRight  = 727;//705; //線終止right //水平所以沒有y坐標(biāo)

  pm_GanFirstLeft = 118;     //最左第一個桿的left坐標(biāo)
  pm_GanOffset    = 60;      //桿間距
  pm_GanTop  = 166;//67;     //桿距頂top
  pm_GanD    = 10;           //桿徑  12
  pm_BYQD    = 13;//14;      //變壓器大小  13
  pm_BYQY    = -7;           //變壓器距桿距離  20

  pm_Distance = 27;//30;     //轉(zhuǎn)角箭頭線段長

  dm_GanTop = 143.25;        //斷面桿
  dm_HaiBa = 0;              //海拔
  dm_HuChui = 5;             //導(dǎo)線下垂弧度

//下面記錄類型用于繪制平斷面圖  
type
  TRecData = record
    XLMC: String;   //線路名稱
    GH: String;     //桿號
    GX: String;     //電桿種類及桿型
    GG: String;     //桿高
    MS: String;     //埋深
    DXPL: String;   //導(dǎo)線排列
    DXXH: String;   //導(dǎo)線型號
    DJ: String;     //檔距
    LJCD: String;   //累計長度
    ZJBZ: Integer;  //畫轉(zhuǎn)角標(biāo)志   1: 畫轉(zhuǎn)角 0: 不畫轉(zhuǎn)角
    ZJ: String;     //線路轉(zhuǎn)角
    JCKY: String;   //交叉跨越
    CZJL: String;   //垂直距離
    HDGG: String;   //橫擔(dān)規(guī)格
    LXWZ: String;   //拉線位置
    LXXHGS: String; //拉線型號/根數(shù)
    JYZXHSL: String;//絕緣子型號/數(shù)量
    GZZSY: String;  //故障指示儀
    BTXS: String;   //變臺型式
    PBRL: String;   //配變?nèi)萘?br>    HM: String;     //戶名
    BLQGG: String;  //避雷器規(guī)格
    BLQSL: String;  //避雷器數(shù)量
    KGGG: String;   //開關(guān)規(guī)格
    KGSL: String;   //開關(guān)數(shù)量
    FZ1ZJ: String;  //分支1轉(zhuǎn)角
    FZ2ZJ: String;  //分支2轉(zhuǎn)角
    FZ1MC: String;  //分支1名稱
    FZ2MC: String;  //分支2名稱
    IsCable: Integer; //是否有電纜 1: 電纜 0: 不是電纜
    IsTJPole: Integer;  //是否是引出分支桿
  end;
  PRecData = ^TRecData;

type
  TWindowObject = record
                    WinHandle  : HWnd;    {Window Handle}
                    WinCaption : String;  {Window Caption Text (If any)}
                    ProcessID  : Integer; {Process the window belongs to}
                    IsVisible  : Boolean; {Is the window visible?}
                    IsEnabled  : Boolean; {Is the window enabled for mouse/keyboard input?}
                    IsIconic   : Boolean; {Is the window minimized?}
                    WindowRect : TRect;   {Window Dimensions}
                    {Add more properties here if you like,
                     then fill them in at the WindowCallback
                     function.}
                  end;
  PTWindowObject = ^TWindowObject;

//Excel操作類
  TExcel = class(TObject)
  private
    MyExcel: Variant;             //存儲Excel對象
    Book :Variant;               //當(dāng)前工作表
    Sheet:Variant;               //當(dāng)前工作表
  protected
    { protected declarations }
    function GetRowNum(TStr:string):Integer;   //獲取指定單元格的行號()
    function GetColNum(TStr:string):Integer; //獲取指定單元格的行號
  public
    { Public declarations }
    IsPageSetup:Boolean;         //是否進(jìn)行了頁面設(shè)置
    Template_Path:string;        //模板路徑
    Template_Name:string;        //模板名稱
    Template_OpenName:String;    //打開的模板的名稱
    ActiveSheet:Integer;      //當(dāng)前活動的頁
    UsedRowBeg:Integer;       //當(dāng)前已使用的起始行
    UsedColBeg:Integer;       //當(dāng)前已使用的起始列
    UsedRowEnd:Integer;       //當(dāng)前已使用的終止行
    UsedColEnd:Integer;       //當(dāng)前已使用的終止列
    CurRowBeg:Integer;        //要使用的起始行
    CurColBeg:Integer;        //要使用的起始列
    CurRowEnd:Integer;        //要使用的終止行
    CurColEnd:Integer;        //要使用的終止列
    //下面為類操作
    Constructor Create();                                        //創(chuàng)建Excel對象
    Destructor Destroy; virtual;                                 //釋放Excel對象
    //Excel操作
    procedure IsVisible(IsOrNo:Boolean);                         //控制Excel是否顯示
    procedure IsAlert(IsOrNo:Boolean);                           //控制Excel是否出現(xiàn)警告存盤的對話框
    function  SetActiveWindowGridVisible(IsVisible:Boolean=True):Boolean;        //設(shè)置當(dāng)前窗口網(wǎng)格的顯示與否
    function  SaveToFile(AFileName:string):Boolean;              //Excel數(shù)據(jù)保存到文件
    procedure ExitExcel;                                         //退出Excel

    //工作簿操作
    function  New_WorkBook:Boolean;                                 //新建工作簿
    function  OpenExcelFile(FileName:string): Boolean;              //打開指定的Excel文件
    function  IsWorkbookExit:Integer;                               //判斷是否存在工作簿
    //工作表操作
    function SetCurrentSheet(SheetNum:Integer):Boolean;             //設(shè)置當(dāng)前工作表
    function GetSheetsNameList(var FileName:TstringList):Boolean;   //得到工作簿中工作表名稱列表
    function GetSheetRange:string;                                  //獲取當(dāng)前工作表中的工作范圍
    function SetSheetPage(APageType,Orientation:Integer;LeftMargin,RightMargin,TopMargin,
             BottomMargin,HeaderMargin,FooterMargin:Double):Boolean;   //對指定的工作表進(jìn)行頁面設(shè)置
    //Range或Cell操作
    function  GetCell(Row,Col:Integer):Variant;                        //得到當(dāng)前工作表中某行某列的值
    procedure SetCell(Value: String; Row, Col: Integer;AType:Integer); //設(shè)置指定單元格的值
    function  GetRangeValue(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):String;                    //獲取指定范圍的值
    function  SetRangeValue(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;AValue:string):Boolean;     //設(shè)置指定范圍的值
    function  InsertPicIntoSheet(ABeginRow,ABeginCol:Integer;APicFile:String):Boolean;//向指定工作表中插入圖片
    function  Sum(BeginRow,BeginCol,EndRow,EndCol:Integer):Double;                    //對指定單元格間的值求和
    //文本框操作
    function  InsertTextBox(AX,AY,AWidth,AHeight:Double;AOrient:Integer=msoTextOrientationHorizontalRotatedFarEast):Variant;//在指定位置插入文本框
    function  SetTextBoxFillStyle(ATextBox:Variant;AVisible:Integer;ATransparency:Double=0):Boolean;  //設(shè)置文本框填充樣式
    function  SetTextBoxLineStyle(ATextBox:Variant;AVisible:Integer;ATransparency:Double=0):Boolean;  //設(shè)置文本框邊框樣式
    function  SetTextBoxFontStyle(ATextBox:Variant;AFontName,AFontStyle:String;
              AFontSize:Integer = 12;AFontColor:Integer=0):Boolean;                     //設(shè)置文本框中字體樣式
    function  SetTextBoxAlignment(ATextBox:Variant;HAlign:Integer=xlLeft;VAlign:Integer=xlBottom):Boolean; //設(shè)置文本框水平和垂直對齊方式
    function  SetTextBoxText(ATextBox:Variant;AText:string):Boolean;                    //設(shè)置文本框中文字內(nèi)容
    //格式化單元格操作
    function  MergeCells(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):Variant;  //合并單元格
    procedure CellAutoFit;                                                              //設(shè)置單元格為自動列寬
    //格式化行高和列寬
    function  SetColumnWidth(AColNum:Integer;AColWidth:Double):Boolean;                 //設(shè)置指定列的寬度
    function  SetRowHeight(ARowNum:Integer;ARowHeight:Double):Boolean;                  //設(shè)置指定行的行高
    function  SetRangeColWidth(ABeginRow,ABeginCol,AEndRow,AEndCol:Integer;AColWidth:Double):Boolean; //設(shè)置指定范圍內(nèi)單元格的列寬
    //格式化指定區(qū)域范圍
    function  SetRangeFontStyle(BeginRow,BeginCol,EndRow, EndCol:Integer;
                                AFontStyle:string='常規(guī)';AFontName:string='宋體';
                                AFontColor:Integer=0;AFontSize:Integer=12):Boolean;               //設(shè)置范圍
    function  SetRowFontStyle(ARowNum:Integer;AFontStyle:string='常規(guī)';AFontName:string='宋體';
                                AFontColor:Integer=0;AFontSize:Integer=12):Boolean;               //設(shè)置指定行的字體樣式
    function  SetColumnFontStyle(AColNum:Integer;AFontStyle:string='常規(guī)';AFontName:string='宋體';
                                 AFontColor:Integer=0;AFontSize:Integer=12):Boolean;              //設(shè)置指定列的字體樣式

    function  SetRangeOutBorderStyle(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;
                                 AWeight:Integer=2;ALineColor:Integer=0;ALineStyle:Integer=xlContinuous):Boolean; //設(shè)置指定范圍的外邊框樣式

    function SetRowOutBorderStyle(ARowNum:Integer;AWeight:Integer=2;
                                 ALineColor:Integer=0;ALineStyle:Integer=xlContinuous):Boolean;        //設(shè)置指定行的外邊框樣式
    function SetColumnOutBorderStyle(AColNum:Integer;AWeight:Integer=2;ALineColor:Integer=0;           //設(shè)置指定列的外邊框樣式
                                ALineStyle:Integer=xlContinuous):Boolean;

    function  SetRangeInnerLineStyle(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;
                   AWeight:Integer=2;ALineColor:Integer=0;ALineStyle:Integer=xlContinuous):Boolean;   //設(shè)置指定范圍的分隔線樣式

    function  SetRowInnerLineStyle(ARowNum:Integer;AWeight:Integer=2;ALineColor:Integer=0;
                                ALineStyle:Integer=xlContinuous):Boolean;                            //設(shè)置指定行的分隔線樣式
    function  SetColumnInnerLineStyle(AColNum:Integer;AWeight:Integer=2;ALineColor:Integer=0;
                                ALineStyle:Integer=xlContinuous):Boolean;                            //設(shè)置指定列的分隔線樣式

    function  SetRangeHorizontalAlignment(ABegRowNum,ABegColNum,AEndRowNum,
                               AEndColNum:Integer;AAlign:Integer=xlLeft):Boolean;               //設(shè)置范圍的水平對其方式
    function  SetRangeVerticalAlignment(ABegRowNum,ABegColNum,AEndRowNum,
                               AEndColNum:Integer;AAlign:Integer=xlBottom):Boolean;             //設(shè)置范圍的垂直對其方式
    function  SetRowHorizontalAlignment(ARowNum:Integer;AAlign:Integer=xlLeft):Boolean;         //設(shè)置指定行的水平對其方式
    function  SetRowVerticalAlignment(ARowNum:Integer;AAlign:Integer=xlBottom):Boolean;         //設(shè)置指定行的垂直平對其方式
    function  SetColumnHorizontalAlignment(AColNum:Integer;AAlign:Integer=xlLeft):Boolean;      //設(shè)置指定列的水平對其方式
    function  SetColumnVerticalAlignment(AColNum:Integer;AAlign:Integer=xlBottom):Boolean;      //設(shè)置指定列的垂直對其方式

    function  SetRangeAutoWrap(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):Boolean;    //設(shè)置指定區(qū)域格式為自動換行
    function  CancelRangeAutoWrap(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):Boolean; //取消指定區(qū)域的自動換行
    function  SetRangeBackGround(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;
               APattern:Integer=xlSolid;APatternColor:Integer=xlNone;ABackColor:Integer=xlNone):Boolean;   //設(shè)置指定范圍的背景圖案

    //格式化箭頭線
    function FormatArrowLineEndHead(ALine:Variant;AheadStyle:Integer=msoArrowheadTriangle;
             AheadLength:Integer=msoArrowheadLengthMedium;AheadWidth:Integer=msoArrowheadWidthMedium):Boolean;  //格式化箭頭線的末端樣式
    function FormatArrowLineBeginHead(ALine:Variant;AheadStyle:Integer=msoArrowheadTriangle;
             AheadLength:Integer=msoArrowheadLengthMedium;AheadWidth:Integer=msoArrowheadWidthMedium):Boolean; //格式化箭頭線的首端樣式
    function  FormatArrowLine(ALine:Variant;AWidth:Double=1.5;AStyle:Integer=msoLineSingle;ADashStyle:Integer=msoLineSolid):Boolean;  //格式化箭頭線的線樣式
    //數(shù)據(jù)庫中數(shù)據(jù)轉(zhuǎn)為Excel操作
    procedure SetTheFieldsName(AFields:TStringList;BeginRow,BeginCol,FieldNumber:Integer;IsNeedXuHao:Boolean); //設(shè)置Excel工作表中的列名
    procedure TransferDataToExcel(FieldValues:Array of TStringList;BeginRow,BeginCol,FieldNumber,RcdNumber:Integer;IsNeedXuHao:Boolean); //轉(zhuǎn)換數(shù)據(jù)到Excel
    procedure DataToExcelUpPage(FieldValues:Array of TStringList;BeginRow,BeginCol,FieldNumber,
              RcdNumber:Integer;IsNeedXuHao:Boolean;IsHengXiangOrZongXiang:Boolean=False); //使用Excel將指定的數(shù)據(jù)打印輸出
    //
    procedure Print_PageSetup();                            //打印頁面設(shè)置
    procedure Print_PrintView;                              //打印預(yù)覽
    procedure Print_PrintOut;                               //打印輸出
    //
    function  Get_Template_Path():String;                  //獲取模板路徑
    procedure Set_Template_Path(PathName:String);          //設(shè)置模板路徑
    procedure Set_Template_OpenName(TemplateName:String);  //設(shè)置打開模板的名稱
    function  Open_Template():Variant;  //打開模板
    procedure Save_Template();  //保存模板
    //
    procedure SetTableTitle(TitleName:String;BeginRow,BeginCol,Row,Col,FontSize:integer;
                            IsNeedXuHao:Boolean=False;IsNeedFrame:Boolean=True);  //設(shè)置表的標(biāo)題(表頭)
    //繪制平斷面圖
    procedure CreatePage(APage: Integer;ABDZMC, AXLMC: String;AValueList: TStringList); //創(chuàng)建頁
    procedure FormatCells(APage, AColNum, ARow: Integer;AColName: String
                                          ;AValueList: TStringList);             //繪制平斷面圖時根據(jù)不同情況格式化單元格
    procedure GetCellDMGanCoord(APage, ACellIndex: Integer;var AX, AY: Double);  //獲取指定頁,指定cell的斷面桿的中心坐標(biāo)
    procedure CreateDMT(AX1, AY1, AGanGao: Double;AIsTJPole, AIsFirstPole,
                 AIsCable: Boolean;var AOldY2: Double);                         //創(chuàng)建斷面圖
    procedure GetCellGanCoord(APage, ACellIndex: Integer;var AX, AY: Double);   //獲取指定頁,指定cell的桿的中心坐標(biāo)
    procedure CreateFZLine(AX, AY,AYOffSet,AAngle: Double;AXLMC: String);       //畫分支  創(chuàng)建轉(zhuǎn)角箭頭線
    procedure CreateArrowheadLine(AX, AY, AAngle: Double);                      //創(chuàng)建轉(zhuǎn)角箭頭線
    function  DoubleToFenMiao(Jiao:Double):string;                              //雙精度的度轉(zhuǎn)換為度分秒
    procedure DrawBYQText(AX, AY : Double;AText: String);                       //繪制變壓器文本
    procedure DrawBYQ(AX, AY : Double);                                         //繪制變壓器
    function GetPoleHight(AHight: Double): Double;                              //以15米桿高為標(biāo)準(zhǔn)計算d當(dāng)前桿塔圖形高度
    //暫不使用的功能
    function  FindTheExcelMainWindow:Integer;          //輔助工程找出當(dāng)前系統(tǒng)環(huán)境中的運行的excel的主窗體句柄:
    procedure DisableSystemCloseBox;                   //使當(dāng)前Excel應(yīng)用程序的關(guān)閉按鈕失效

    //
  Published
    { Published declarations }
  end;

const
  RcdCountOfEachPageOfHengXiang=22;
  RcdCountOfEachPageOfZongXiang=44;

var
  MyWindowPtr : ^TWindowObject;
  V_PageOffset: Double;

implementation {實現(xiàn)部分}



{ Excel }


{
功能描述:創(chuàng)建Excel對象
輸入?yún)?shù): 無
輸出參數(shù):無
創(chuàng)建時間: 2006-04-07
創(chuàng)建人:  趙占輕
}
constructor TExcel.Create();
begin
  Inherited;
  try
    MyExcel:=CreateOleObject('Excel.Application');             //創(chuàng)建Excel對象
  except
  end;
  //
//  New(MyWindowPtr);
  //
end;

{
功能描述:使用Excel將指定的數(shù)據(jù)打印輸出
輸入?yún)?shù):FieldValues              待輸出的數(shù)據(jù)列表
          BeginRow                 起始行號
          BeginCol                 起始列號
          FieldNumber              字段數(shù)
          RcdNumber                記錄數(shù)
          IsNeedXuHao              是否需要序號
          IsHengXiangOrZongXiang   縱向還是橫向 (True:縱向False:橫向)
輸出參數(shù):無
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
procedure TExcel.DataToExcelUpPage(FieldValues: array of TStringList; BeginRow,
  BeginCol, FieldNumber, RcdNumber: Integer; IsNeedXuHao: Boolean;IsHengXiangOrZongXiang:Boolean=False);
var
  nPageNumber,nLastPageRcdCount,i,nTmp:Integer;
  vSheet:Variant;
begin
  if IsHengXiangOrZongXiang then
  begin
    nLastPageRcdCount:=(RcdNumber mod RcdCountOfEachPageOfZongXiang);
    nPageNumber:=((RcdNumber-nLastPageRcdCount) div RcdCountOfEachPageOfZongXiang);
    ntmp:=RcdCountOfEachPageOfZongXiang;
  end else
  begin
    nLastPageRcdCount:=(RcdNumber mod RcdCountOfEachPageOfHengXiang);
    nPageNumber:=((RcdNumber-nLastPageRcdCount) div RcdCountOfEachPageOfHengXiang);
    nTmp:=RcdCountOfEachPageOfHengXiang;
  end;//
  //循環(huán)執(zhí)行打印工作:
  for i:=1 to nPageNumber do
  begin
    try
      vSheet:=Open_Template;                 //打開模板
    except
      MyExcel.Quit;
      Exit;
    end;//
    TransferDataToExcel(FieldValues,BeginRow,BeginCol,FieldNumber,ntmp,IsNeedXuHao);    //數(shù)據(jù)輸出到Excel
    try
      Print_PrintOut;            //從Excel中打印輸出
    except
      ShowMessage('打印機(jī)錯誤,請檢查你的打印機(jī)設(shè)備是否正常!');
      Exit;
    end;//
  end;//
  //執(zhí)行剩余打印工作:
  if nLastPageRcdCount>0 then
  begin
    try
      vSheet:=Open_Template;
    except
      MyExcel.Quit;
      Exit;
    end;//
    TransferDataToExcel(FieldValues,BeginRow,BeginCol,FieldNumber,nLastPageRcdCount,IsNeedXuHao);
    try
      Print_PrintOut;
    except
      ShowMessage('打印機(jī)錯誤,請檢查你的打印機(jī)設(shè)備是否正常!');
      Exit;
    end;//
  end;//
end;

{
功能描述:釋放Excel對象變量
輸入?yún)?shù):無
輸出參數(shù): 無
創(chuàng)建時間:2006-04-07
創(chuàng)建人:  趙占輕
}
destructor TExcel.Destroy;
begin
  //
  inherited;
  MyExcel:=UnAssigned;
end;

{
功能描述:使Excel程序關(guān)閉按鈕失效
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-18
創(chuàng)建人:  劉惠城
}
procedure TExcel.DisableSystemCloseBox;
var
  hExcelWindow : HWND;
  hSysMenu    : HMENU;
  nrlt:Integer;
begin
  // Find the Excel2000 handle
  nrlt:=FindTheExcelMainWindow;
  if nrlt=0 then
  begin
    Exit;
  end
  else
  begin
    hExcelWindow:=MyWindowPtr.WinHandle;
  end;//
  if hExcelWindow <> 0 then
  begin
    hSysMenu := GetSystemMenu (hExcelWindow, false);
    EnableMenuItem (hSysMenu, SC_CLOSE, MF_DISABLED)
  end;
end;
//-------------------------------------------------------------------------//

{
功能描述:退出Excel
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2003-11-09
創(chuàng)建人:  徐偉亮
}
procedure TExcel.ExitExcel;
begin
  try
    Book.Saved:=True;           //自動退出Excel時保存修改內(nèi)容
  except
  end;
  MyExcel.Quit;
end;

{
功能描述:輔助工程找出當(dāng)前系統(tǒng)環(huán)境中的運行的excel的主窗體句柄
輸入?yún)?shù):無
輸出參數(shù):1:找到結(jié)果;0:未找到結(jié)果
創(chuàng)建時間:2006-04-18
創(chuàng)建人:  劉惠城
}
function TExcel.FindTheExcelMainWindow:Integer;//will alter
  function WindowCallback(WHandle : HWnd; Var Parm : Pointer) : Boolean; stdcall;
  {This function is called once for each window}
  Var MyString : PChar;
      MyInt : Integer;
      caption1:PChar;
  begin
    caption1:='Microsoft Excel';
    MyString := Allocmem(255);
    GetWindowText(WHandle,MyString,255);
    if StrPos(MyString,caption1)=nil then
    begin
      //FreeMem(caption1,16);
      Result := True;//Not find,continue to enumerate windows;
      Exit;
    end;//
    //
    {Window Handle (Passed by the enumeration)}
    MyWindowPtr.WinHandle := WHandle;
    {Window text}
    MyWindowPtr.WinCaption := String(MyString);
    FreeMem(MyString,255);

    {Process ID}
    MyInt := 0;
    MyWindowPtr.ProcessID := GetWindowThreadProcessId(WHandle,@MyInt);

    {Visiblity}
    MyWindowPtr.IsVisible := IsWindowVisible(WHandle);

    {Enabled}
    MyWindowPtr.IsEnabled := IsWindowEnabled(WHandle);

    {Iconic}
    MyWindowPtr.IsIconic := IsIconic(WHandle);

    {Window Dimensions}
    MyWindowPtr.WindowRect := Rect(0,0,0,0);
    GetWindowRect(WHandle,MyWindowPtr.WindowRect);
    //
    Result := False; {Everything's okay.Stop to enumerate windows}
  end;
  //
begin
  //
  EnumWindows(@WindowCallback,0);
  if MyWindowPtr.WinHandle = 0 then
    begin
      Result:=0;
    end else
    begin
      Result:=1;
    end;
end;

{
功能描述:獲取模板路徑
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:   趙占輕
}
function TExcel.Get_Template_Path: String;
begin
  //
  Result:=Template_Path;
end;

{
功能描述:控制是否出現(xiàn)警告存盤的對話框;
輸入?yún)?shù):IsOrNo:控制是否顯示提示框
             (True:顯示提示框;False:不顯示提示框)
輸出參數(shù):無
創(chuàng)建時間:2006-04-07
創(chuàng)建人:  趙占輕
}
procedure TExcel.IsAlert(IsOrNo: Boolean);
begin
  MyExcel.DisplayAlerts:=IsOrNo;                 //是否出現(xiàn)警告存盤的對話框;
end;

{
功能描述:控制是否顯示Excel
輸入?yún)?shù):IsOrNo:
          (True:顯示Excel;False:不顯示Excel)
輸出參數(shù):無
創(chuàng)建日期:2003-10-20
創(chuàng)建人:  趙占輕
}
procedure TExcel.IsVisible(IsOrNo: Boolean);
begin
  if IsOrNo then
  begin
    MyExcel.Visible:= True;
  end else
  begin
    MyExcel.Visible :=False;
  end;
end;

{
功能描述:判斷是否存在工作簿
輸入?yún)?shù):無
輸出參數(shù):0:不存在工作簿;1:存在工作簿
創(chuàng)建時間:2006-04-07
創(chuàng)建人:  趙占輕
}
function TExcel.IsWorkbookExit: Integer;
var
  nBookCount:Integer;
begin
  nBookCount:=MyExcel.Workbooks.Count;      //獲取工作簿數(shù)量
  if nBookCount<=0 then
  begin
    Result:=0;
    Exit;
  end;//
  Result:=1;
end;

{
功能描述:新建工作簿
輸入?yún)?shù):無
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-14
創(chuàng)建人:  趙占輕
}
function TExcel.New_WorkBook:Boolean;
begin
  {在啟動Excel之前,最好將以前運行的實例關(guān)閉
  因為有時會出現(xiàn)異常的情況;}
  //啟動Excel應(yīng)用程序:
  Result:=False;
  try
    if MyExcel.Workbooks.Count>=1 then             //如果Excel已經(jīng)啟動,
    begin                                      //且工作薄存在,則置
      Book:=MyExcel.Workbooks[1];                //第一個工作薄為當(dāng)前
      Sheet:=MyExcel.Workbooks [1].Worksheets[1];//工作薄;
      Exit;
    end;//
    Book:=MyExcel.Workbooks.Add;
    if MyExcel.Worksheets.Count>=1 then
    begin
      Sheet:=Book.Worksheets.Item[1];
    end;
  except
    Exit;
  end;
  Result:=True;
end;

{
功能描述:打開模板
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
function TExcel.Open_Template:Variant;
var
  sTmp:String;
begin
  //打開模板
  if MyExcel.Workbooks.Count>=1 then
  begin
    Book:=MyExcel.Workbooks[1];
    Book.Close;
  end;//
  sTmp:=Template_Path+Template_OpenName;
  Book:=MyExcel.Workbooks.Add (sTmp,0);
  Result:=MyExcel.Workbooks [1].Worksheets[1];
end;

{
功能描述:打印頁面設(shè)置
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.Print_PageSetup;
begin
  //打印設(shè)置
  IsPageSetup:=MyExcel.Dialogs.Item[xlDialogPageSetup].Show(
   EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
end;

{
功能描述:打印輸出
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.Print_PrintOut;
begin
  Sheet.PrintOut(EmptyParam);
end;

{
功能描述:打印預(yù)覽
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.Print_PrintView;
begin
  Sheet.PrintPreview;
end;

{
功能描述:保存模板
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.Save_Template;
var
  sTmp:String;
begin
  //保存模板
  sTmp:=Template_Path+Template_Name;
  Book.SaveAs(sTmp,xlTemplate);
end;

{
功能描述:設(shè)置表的標(biāo)題
輸入?yún)?shù):TitleName    標(biāo)題名稱
          BeginRow     開始行
          BeginCol     開始列
          Row          所占用的行數(shù)
          Col          列數(shù)
          FontSize     字體大小
          IsNeedXuHao  是否需要序號
          IsNeedFrame  是否需要框架
輸出參數(shù):無
創(chuàng)建時間:2003-10-20
創(chuàng)建人:  趙占輕
}
procedure TExcel.SetTableTitle(TitleName: String;
                               BeginRow,BeginCol,Row, Col,FontSize: integer;
                               IsNeedXuHao:Boolean=False;IsNeedFrame:Boolean=True);
var
  vRange,vCell1,vCell2:Variant;
  nCol,nRow:Integer;
  sTitleName:String;
begin
  sTitleName:=TitleName;                      //記錄標(biāo)題名
  nCol:=Col;                                    //記錄標(biāo)題所占用的列數(shù)
  nRow:=Row;                                    //記錄標(biāo)題所占用的行數(shù)
  vCell1:=Sheet.Cells[BeginRow,BeginCol];        //記錄起始單元格
  if IsNeedXuHao then                           //需要序號
  begin
    MergeCells(BeginRow,BeginCol,nRow,nCol+1);               //合并單元格
    SetRangeHorizontalAlignment(BeginRow,BeginCol,nRow,nCol+1,xlHAlignCenter);//水平對其方式為居中
    SetRangeVerticalAlignment(BeginRow,BeginCol,nRow,nCol+1,xlVAlignCenter); //垂直對其方式為居中
    //設(shè)置字體樣式
    SetRangeFontStyle(BeginRow,BeginCol,nRow,nCol+1,'正常','宋體',5,FontSize);         //設(shè)置指定范圍的字體樣式
    SetRangeValue(BeginRow,BeginCol,nRow,nCol+1,sTitleName);     //設(shè)置標(biāo)題
    if IsNeedFrame then                           //需要邊框
    begin
      SetRangeOutBorderStyle(BeginRow,BeginCol,nRow,nCol,1,0,1);
    end;  
  end
  else                                          //不需要序號
  begin
    MergeCells(BeginRow,BeginCol,nRow,nCol);               //合并單元格
    SetRangeHorizontalAlignment(BeginRow,BeginCol,nRow,nCol,xlHAlignCenter);//水平對其方式為居中
    SetRangeVerticalAlignment(BeginRow,BeginCol,nRow,nCol,xlVAlignCenter); //垂直對其方式為居中
    //設(shè)置字體樣式
    SetRangeFontStyle(BeginRow,BeginCol,nRow,nCol,'正常','宋體',5,FontSize);         //設(shè)置指定范圍的字體樣式
    SetRangeValue(BeginRow,BeginCol,nRow,nCol,sTitleName);
    if IsNeedFrame then                           //需要邊框
    begin
      SetRangeOutBorderStyle(BeginRow,BeginCol,nRow,nCol,1,0,1);
    end;  
  end;
end;

{
功能描述:設(shè)置Excel工作表中的列名
輸入?yún)?shù): AFields      列名列表
          BeginRow     起始行號
          BeginCol     起始列號
          FieldNumber  列數(shù)
          IsNeedXuHao  是否需要序號
輸出參數(shù):無
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
procedure TExcel.SetTheFieldsName(AFields:TStringList;BeginRow,BeginCol,FieldNumber:Integer;IsNeedXuHao:Boolean);
var
  vRange,vCell1,vCell2:Variant;
  nCol,i,j:Integer;
  sValue:String;
begin
  nCol:=BeginCol+FieldNumber-1;
  //從數(shù)據(jù)庫中讀出字段名并輸出到第一列:
  vCell1:=Sheet.Cells[BeginRow,BeginCol];
  vCell2:=Sheet.Cells[BeginRow,nCol];
  vRange:=Sheet.Range[vCell1,vCell2];
//  SetRangeFontStyle(vRange,'常規(guī)','宋體',5,13);      //設(shè)置指定范圍的字體樣式
  if IsNeedXuHao then
  begin
    Sheet.Cells[BeginRow,BeginCol]:='序號';
    for i:=BeginCol to FieldNumber do
    begin
      sValue:=AFields[i-1];
      Sheet.Cells[BeginRow,i+1]:=sValue;
      Sheet.Cells[BeginRow,i+1].Borders.LineStyle:=1;
    end;
    exit;
  end;
  //-----------------------------------------//
  j:=0;
  for i:=BeginCol to FieldNumber+BeginCol-1 do
    begin
      sValue:=AFields[j];
      Sheet.Cells[BeginRow,i].Borders.LineStyle:=1;
      Sheet.Cells[BeginRow,i]:=sValue;
      Sheet.Cells[BeginRow,i].HorizontalAlignment:= xlHAlignCenter;
      Sheet.Cells[BeginRow,i].VerticalAlignment:=xlVAlignCenter;
      j:=j+1;
    end;
end;

{
功能描述:設(shè)置打開模板的名稱
輸入?yún)?shù): TemplateName:模板名稱
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.Set_Template_OpenName(TemplateName: String);
begin
  //
  Template_OpenName:=TemplateName;
end;

{
功能描述:設(shè)置模板路徑
輸入?yún)?shù):PathName:路徑名
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.Set_Template_Path(PathName: String);
begin
  //
  Template_Path:=PathName;
end;

{
功能描述:轉(zhuǎn)換數(shù)據(jù)到Excel
輸入?yún)?shù):FieldValues  字段值列表
          BeginRow     起始行號
          BeginCol     起始列號
          FieldNumber  字段數(shù)
          RcdNumber    記錄數(shù)
          IsNeedXuHao  是否需要序號
輸出參數(shù):無
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
procedure TExcel.TransferDataToExcel(FieldValues:Array of TStringList; BeginRow, BeginCol,
  FieldNumber,RcdNumber: Integer; IsNeedXuHao: Boolean);
var
  i,j,nSerial:Integer;
  sValue:String;
begin
  //
  //設(shè)置序號值:
  if IsNeedXuHao then
  begin
    nSerial:=1;
    for i:=BeginRow to BeginRow+RcdNumber do                             //
    begin
       //
      Sheet.Cells[i,BeginCol].Borders.LineStyle:=1;
      Sheet.Cells[i,BeginCol]:=nSerial;
      Sheet.Cells[i,BeginCol].HorizontalAlignment:= xlHAlignCenter;
      Sheet.Cells[i,BeginCol].VerticalAlignment:=xlVAlignCenter;
      //
      if i=BeginRow+RcdNumber-1 then
      begin
        break;
      end;//
      nSerial:=nSerial+1;
    end;//
    BeginCol:=BeginCol+1;
  end;//
  // 傳輸數(shù)據(jù)到Excel工作表
  for i:=0 to RcdNumber-1 do
  begin
    for j:=0 to FieldNumber-1 do
    begin
      sValue:=FieldValues[i][j] ;
      Sheet.Cells[BeginRow+i,BeginCol+j].Borders.LineStyle:=1;
      Sheet.Cells[BeginRow+i,BeginCol+j]:=sValue;
      Sheet.Cells[BeginRow+i,BeginCol+j].HorizontalAlignment:= xlHAlignCenter;
      Sheet.Cells[BeginRow+i,BeginCol+j].VerticalAlignment:=xlVAlignCenter;
    end;//
  end;//
end;

{
功能描述:得到當(dāng)前工作表中某行某列的值
輸入?yún)?shù):Row:指定行號;
          Col:指定單元格列號
輸出參數(shù):返回指定單元格的值
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
function TExcel.GetCell(Row,Col:Integer):Variant;
begin
  if (Row=0) or (Col=0) then
  begin
    Result:=-1;
    Exit;
  end;
  Result:=Sheet.Cells[Row,Col];
end;

{
功能描述:對指定單元格間的值求和
輸入?yún)?shù):BeginRow   起始單元格的行號
          BeginCol   起始單元格的列號
          EndRow     終止單元格的行號
          EndCol     終止單元格的列號
輸出參數(shù):返回總和值
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
function TExcel.Sum(BeginRow,BeginCol,EndRow,EndCol:Integer):Double;
var
  dTotal:Double;
  vRange,vCell1,vCell2:Variant;
begin
  vCell1:=Sheet.Cells[BeginRow,BeginCol];          //獲取起始單元格
  vCell2:=Sheet.Cells[EndRow,EndCol];              //獲取終止單元格
  vRange:=MyExcel.Range[vCell1,vCell2];
  //計算總和
  dTotal:=MyExcel.Sum (vRange,vRange,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam
  ,EmptyParam,EmptyParam);

  //
  Result:=dTotal/2.0;
end;//

{
功能描述:設(shè)置指定單元格的值
輸入?yún)?shù):Value: 設(shè)置的單元格的值
          Row:  指定單元格的行號
          Col:   指定單元格的列號
          AType:單元格值的類型  (0:字符型;1:整形;2,3:數(shù)值型)
輸出參數(shù):無
創(chuàng)建時間:2006-04-11
創(chuàng)建人:  趙占輕
}
procedure TExcel.SetCell(Value: String; Row, Col: Integer;AType:Integer);
begin
  case AType of
    0: //字符型
      begin
        //格式化單元格為文本樣式,確保數(shù)據(jù)格式正確
        Sheet.Cells[Row,Col].NumberFormatLocal:='@';
      end;
    1:  //整型
      begin
        Sheet.Cells[Row,Col].NumberFormatLocal:='0';
      end;
    2:
      begin
        //格式化單元格為文本樣式,確保數(shù)據(jù)格式正確
        Sheet.Cells[Row,Col].NumberFormatLocal:='0.00000';
      end;
    3: //浮點型
      begin
        Sheet.Cells[Row,Col].NumberFormatLocal:='0.00000';
      end;
  end;
  Sheet.Cells[Row,Col]:=Value;
end;

{
功能描述:設(shè)置單元格為自動列寬
輸入?yún)?shù):無
輸出參數(shù):無
創(chuàng)建時間:2003-11-20
創(chuàng)建人:  趙占輕
}
procedure TExcel.CellAutoFit;
begin
  MyExcel.Columns.AutoFit;
end;

{
功能描述: 打開指定的Excel文件
輸入?yún)?shù): FileName:要打開的文件名   如:c:\test.xls
輸出參數(shù): 執(zhí)行成功返回真否則返回假
創(chuàng)建時間: 2006-04-07
設(shè)計人:   趙占輕
}
function TExcel.OpenExcelFile(FileName: string): Boolean;
begin
  Result:=False;
  try
    Book:=MyExcel.Workbooks.Open(FileName);
    Sheet:=Book.WorkSheets.Item[1];
  except
    Exit;
  end;
  Result:=True;
end;


{
功能描述:    得到指定的工作表
輸入?yún)?shù):    SheetNum:工作表順序號;ASheet:記錄獲取的工作表
輸出參數(shù):    執(zhí)行成功返回真否則返回假
輸入輸出參數(shù):ASheet:返回獲取的工作表
創(chuàng)建時間:    2006-04-11
創(chuàng)建人:       趙占輕
}

{
功能描述:獲取當(dāng)前活動工作簿中指定工作表的工作范圍
輸入?yún)?shù):ASheet:要操作的工作表;SheetNum:指定工作簿中工作表的序號
輸出參數(shù):工作區(qū)地址字符串 如"A1:Z200"
創(chuàng)建時間: 2006-04-07
創(chuàng)建人:   趙占輕
}
function TExcel.GetSheetRange:string;
var
  sTemp:String;
  i:Integer;
begin
  sTemp:=Sheet.UsedRange.AddressLocal;                //取指定工作表中的工作范圍
  //分析字符串提取行列號
  for i:=1 to Length(sTemp) do
  begin
    if sTemp[i]<>'$' then
    begin
      Result:=Result+sTemp[i];
    end;
  end;
  if Pos(':',ReSult)=0 then
  begin
    UsedRowBeg:=GetRowNum(ReSult);  //起始行號
    UsedColBeg:=GetColNum(Result);  //起始列號
    UsedRowEnd:=UsedRowBeg;           //終止行號
    UsedColEnd:=UsedColBeg;           //終止列號
    Result:=Result+':'+Result;
  end
  else
  begin
    sTemp:=Copy(Result,1,Pos(':',Result)-1);
    UsedRowBeg:=GetRowNum(sTemp); //起始行號
    UsedColBeg:=GetColNum(sTemp); //其實列號
    sTemp:=Copy(Result,Pos(':',Result)+1,Length(Result)-Pos(':',Result));
    UsedRowEnd:=GetRowNum(sTemp);  //終止行號
    UsedColEnd:=GetColNum(sTemp);  //終止列號
  end;
end;

{
功能描述:獲取指定單元格的列號
輸入?yún)?shù): TStr:單元格地址
輸出參數(shù): 單元格列號
創(chuàng)建時間: 2006-04-07
創(chuàng)建人:   趙占輕
}
function TExcel.GetColNum(TStr:string):Integer;
begin
  Result:=StrToInt(Sheet.Range[TStr].Cells.Column);
end;

{
功能描述:獲取指定單元格的行號
輸入?yún)?shù): TStr:單元格地址
輸出參數(shù): 單元格行號
創(chuàng)建時間: 2006-04-07
創(chuàng)建人:   趙占輕
}
function TExcel.GetRowNum(TStr:string):Integer;
begin
  Result:=StrToInt(Sheet.Range[TStr].Cells.Row);
end;

{
功能描述:    得到當(dāng)前工作簿中所有工作表名稱
輸入?yún)?shù):    FileName:用于返回獲取的所有工作表名稱
輸出參數(shù):    操作結(jié)果 True:執(zhí)行成功;False: 執(zhí)行失敗
輸入輸出參數(shù):FileName:用于返回獲取的所有工作表名稱
創(chuàng)建時間:    2003-10-24
創(chuàng)建人:      趙占輕
}
function TExcel.GetSheetsNameList(var FileName:TstringList):Boolean;
var
  i:Integer;
  vSheet:Variant;
begin
  try
    for i:=1 to MyExcel.ActiveWorkbook.Sheets.Count do
    begin
      vSheet:=MyExcel.ActiveWorkbook.Worksheets[i];       //獲取第i個工作表
      FileName.Add(VSheet.Name);                          //記錄第i個工作表的名稱
    end;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:合并單元格
輸入?yún)?shù):ABegRowNum:  待合并單元格的起始行號
          ABegColNum:   起始列號
          AEndRowNum:  終止行號
          AEndColNum:  終止列號
輸出參數(shù): 返回合并后的單元格
創(chuàng)建時間: 2006-04-11
創(chuàng)建人:  趙占輕
}
function  TExcel.MergeCells(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):Variant;           //合并單元格
var
  vRange:Variant;
  vBegCell,vEndCell:Variant;
begin
  try
    vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];              //獲取指定單元格間的范圍
    vRange.Merge;                                  //合并單元格
    Result:=vRange;
  except
    Result:=Null;
  end;
end;

{
功能描述:設(shè)置指定范圍單元格的字體樣式
輸入?yún)?shù):BeginRow    指定范圍的起始單元格行號;
          BeginCol    指定范圍的起始單元格列號;
          EndRow      指定范圍的終止單元格行號
          EndCol      指定范圍的終止單元格列號
          AFontStyle  目標(biāo)字體樣式(如粗體);
          AFontName   目標(biāo)字體名稱;
          AFontSize   目標(biāo)字體大小
          AFontColor  目標(biāo)字體顏色
輸出參數(shù):執(zhí)行成功返回真;否則返回假
創(chuàng)建時間:2006-04-12
創(chuàng)建人:  趙占輕
}
function TExcel.SetRangeFontStyle(BeginRow,BeginCol,EndRow, EndCol:Integer;
                                AFontStyle:string='常規(guī)';AFontName:string='宋體';
                                AFontColor:Integer=0;AFontSize:Integer=12):Boolean;  //設(shè)置范圍  
var
  vRange:Variant;
  vBegCel,vEndCell:Variant;
begin
  try
    vBegCel:=Sheet.Cells[BeginRow,BeginCol];
    vEndCell:=Sheet.Cells[EndRow, EndCol];
    vRange:=Sheet.Range[vBegCel,vEndCell];
    vRange.Font.ColorIndex:=AFontColor;                 //設(shè)置字體顏色
    vRange.Font.Name:=AFontName;                        //設(shè)置字體名稱
    vRange.Font.Size:=AFontSize;                        //設(shè)置字體大小
    vRange.Font.FontStyle:=AFontStyle;                  //設(shè)置字體樣式
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定范圍的外邊框樣式
輸入?yún)?shù):ABegRowNum    待設(shè)置范圍的起始行號
          ABegColNum    待設(shè)置范圍的起始列號
          AEndRowNum    待設(shè)置范圍的終止行號
          AEndColNum    待設(shè)置范圍的終止列號
          AWeight       邊線粗度
          ALineColor    邊線顏色
          ALineStyle    邊線樣式
          
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕
}
function TExcel.SetRangeOutBorderStyle(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;
                                 AWeight:Integer=2;ALineColor:Integer=0;ALineStyle:Integer=xlContinuous):Boolean;
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
  vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
  vRange:=Sheet.Range[vBegCell,vEndCell];
  try
    //設(shè)置左邊框
    vRange.Borders.Item[xlEdgeLeft].LineStyle :=ALineStyle;
    vRange.Borders.Item[xlEdgeLeft].Weight := AWeight;
    vRange.Borders.Item[xlEdgeLeft].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置頂邊框
    vRange.Borders.Item[xlEdgeTop].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeTop].Weight := AWeight;
    vRange.Borders.Item[xlEdgeTop].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置底邊框
    vRange.Borders.Item[xlEdgeBottom].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeBottom].Weight := AWeight;
    vRange.Borders.Item[xlEdgeBottom].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置右邊框
    vRange.Borders.Item[xlEdgeRight].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeRight].Weight := AWeight;
    vRange.Borders.Item[xlEdgeRight].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定范圍的分隔線樣式
輸入?yún)?shù):ABegRowNum   待設(shè)置范圍的起始行號
          ABegColNum   待設(shè)置范圍的起始列號
          AEndRowNum   待設(shè)置范圍的終止行號
          AEndColNum   待設(shè)置范圍的終止列號
          AWeight      分割線粗度
          ALineColor   分割線顏色
          ALineStyle   分割線樣式
          
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function  TExcel.SetRangeInnerLineStyle(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;
                   AWeight:Integer=2;ALineColor:Integer=0;ALineStyle:Integer=xlContinuous):Boolean;        //設(shè)置指定范圍的分隔線樣式
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
  vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
  vRange:=Sheet.Range[vBegCell,vEndCell];
  try
    //設(shè)置垂直線樣式
    vRange.Borders.Item[xlInsideVertical].LineStyle :=ALineStyle;
    vRange.Borders.Item[xlInsideVertical].Weight := AWeight;
    vRange.Borders.Item[xlInsideVertical].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置水平線樣式
    vRange.Borders.Item[xlInsideHorizontal].LineStyle := ALineStyle;
    vRange.Borders.Item[xlInsideHorizontal].Weight := AWeight;
    vRange.Borders.Item[xlInsideHorizontal].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置當(dāng)前工作表,并將指定的工作表存儲到類屬性Sheet中供其他操作使用
輸入?yún)?shù):待指定的工作表的序號
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function TExcel.SetCurrentSheet(SheetNum:Integer):Boolean;             //設(shè)置當(dāng)前工作簿
begin
  Result:=False;
  try
    Sheet:=MyExcel.Worksheets.Item[SheetNum];
    Result:=True;
  except
  end;
end;

{
功能描述:設(shè)置范圍的水平對其方式
輸入?yún)?shù):ABegRowNum   待設(shè)置的范圍的起始行號
          ABegColNum   待設(shè)置的范圍的起始列號
          AEndRowNum   待設(shè)置的范圍的終止行號
          AEndColNum   待設(shè)置的范圍的終止列號
          AAlign       對其方式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function TExcel.SetRangeHorizontalAlignment(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;AAlign:Integer=xlLeft):Boolean;
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    vRange.HorizontalAlignment:= AAlign;   //水平對其方式為居中
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置范圍的垂直對其方式
輸入?yún)?shù):ABegRowNum          待設(shè)置的范圍起始行號
          ABegColNum          待設(shè)置的范圍起始列號
          AEndRowNum          待設(shè)置的范圍終止行號
          AEndColNum          待設(shè)置的范圍終止列號
          AAlign              對其方式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function TExcel.SetRangeVerticalAlignment(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;AAlign:Integer=xlBottom):Boolean;  //設(shè)置范圍的垂直對其方式
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    vRange.VerticalAlignment:= AAlign;   //垂直對其方式為居中
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:對指定的工作表進(jìn)行頁面設(shè)置
輸入?yún)?shù):APageType:       紙張類型;
          Orientation:      頁面方向(橫向或縱向)
          LeftMargin:      左邊距
          RightMargin:     右邊距
          TopMargin:       上邊距
          BottomMargin:    下邊距
          HeaderMargin:    頁眉到頂端邊距
          FooterMargin:     頁腳到底端邊距
          
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間: 2006-04-18
創(chuàng)建人:  趙占輕
}
function TExcel.SetSheetPage(APageType,Orientation:Integer;LeftMargin,RightMargin,
         TopMargin,BottomMargin,HeaderMargin,FooterMargin:Double):Boolean;
begin
  try
    //頁面設(shè)置
    Sheet.PageSetup.PaperSize := APageType;   //     設(shè)定紙張
    Sheet.PageSetup.Orientation := Orientation;//     橫向紙張
    //設(shè)定頁邊距
    Sheet.PageSetup.LeftMargin := MyExcel.InchesToPoints(LeftMargin);
    Sheet.PageSetup.RightMargin := MyExcel.InchesToPoints(RightMargin);
    Sheet.PageSetup.TopMargin := MyExcel.InchesToPoints(TopMargin);
    Sheet.PageSetup.BottomMargin := MyExcel.InchesToPoints(BottomMargin);  //1cm
    Sheet.PageSetup.HeaderMargin := MyExcel.InchesToPoints(HeaderMargin);
    Sheet.PageSetup.FooterMargin := MyExcel.InchesToPoints(FooterMargin);
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定列的寬度
輸入?yún)?shù):AColNum:   待設(shè)置的列的列號
          AColWidth:目標(biāo)列寬
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function TExcel.SetColumnWidth(AColNum:Integer;AColWidth:Double):Boolean;
begin
  try
    Sheet.Columns[AColNum].ColumnWidth:=AColWidth;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;

end;

{
功能描述:設(shè)置指定范圍內(nèi)單元格的列寬
輸入?yún)?shù):ABeginRow  指定范圍的起始行號
          ABeginCol  指定范圍的起始列號
          AEndRow    指定范圍的終止行號
          AEndCol    指定范圍的終止列號
          AColWidth:列寬
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetRangeColWidth(ABeginRow,ABeginCol,AEndRow,AEndCol:Integer;AColWidth:Double):Boolean;
var
  vRange,vBeginCell,vEndCell:Variant;
begin
  try
    vBeginCell:=Sheet.Cells[ABeginRow,ABeginCol];
    vEndCell:=Sheet.Cells[AEndRow,AEndCol];
    vRange:=Sheet.Range[vBeginCell,vEndCell];
    vRange.ColumnWidth:=AColWidth;
 except
   Result:=False;
   Exit;
 end;
 Result:=True;
end;

{
功能描述:繪制平斷面圖時根據(jù)不同情況格式化單元格
輸入?yún)?shù):APage      當(dāng)前頁號
          AColNum    列數(shù)
          ARow       行號
          AColName   列名
          AValueList 待填充的值的列表
輸出參數(shù):無
創(chuàng)建時間:2006-04-18
創(chuàng)建人:  趙占輕
}
procedure TExcel.FormatCells(APage, AColNum, ARow: Integer;AColName: String;AValueList: TStringList);
var
  nBegRow,nEndRow:Double;
  i: Integer;
  sValue: String;
  nIndex: Integer;
  dX,dY: Double;
  dX1, dY1: Double;
  nPageTop:Integer;
  dAngle: Double;
  dOldY2: Double;
  dGanGao: Double;
  bIsFirstPole, bIsTJPole: Boolean;
  bIsCable: Boolean;
begin
  dAngle:=0;
  nPageTop := (APage-1)*pm_PageRows;        //每頁行數(shù)
  //處理行高
  case ARow of
    6, 13:
      begin
        //情況特殊,需要加高
        Sheet.Rows[nPageTop+ARow].RowHeight := 28;
      end;
    18:
      begin
        //情況特殊,需要加高
        Sheet.Rows[nPageTop+ARow].RowHeight := 33;
      end;
    else
      begin
        Sheet.Rows[nPageTop+ARow].RowHeight := 15;
      end;
  end;
  //列頭
  MergeCells(nPageTop+ARow,1,nPageTop+ARow,2);
  SetRangeOutBorderStyle(nPageTop+ARow,1,nPageTop+ARow,2,1,0,1);
  SetRangeFontStyle(nPageTop+ARow,1,nPageTop+ARow,2,'常規(guī)','宋體',1,11);
  SetRangeHorizontalAlignment(nPageTop+ARow,1,nPageTop+ARow,2,xlCenter);
  SetRangeVerticalAlignment(nPageTop+ARow,1,nPageTop+ARow,2,xlCenter);
  SetRangeValue(nPageTop+ARow,1,nPageTop+ARow,2,AColName);
  if (ARow = 10)or(ARow = 11)or(ARow = 13) then        //檔距和累計長度特殊
  begin
    //合并第一個格
    SetRangeOutBorderStyle(nPageTop+ARow,3,nPageTop+ARow,3,1,0,1);
    SetRangeFontStyle(nPageTop+ARow,3,nPageTop+ARow,3,'常規(guī)','宋體',1,11);
    SetRangeHorizontalAlignment(nPageTop+ARow,3,nPageTop+ARow,3,xlCenter);
    SetRangeVerticalAlignment(nPageTop+ARow,3,nPageTop+ARow,3,xlCenter);

    nIndex := (APage-1)*AColNum;
    if nIndex <= AValueList.Count -1 then    //防止數(shù)據(jù)溢出
    begin
      case ARow of
        10: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.DJ;
        11: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.LJCD;
        13: SValue := PRecData(Integer(AValueList.Objects[nIndex]))^.JCKY;
      end;
      if sValue <> '0' then
      begin
        SetRangeValue(nPageTop+ARow,3,nPageTop+ARow,3,sValue);
      end;
    end;
    //合并最后一個格
    SetRangeOutBorderStyle(nPageTop+ARow,24,nPageTop+ARow,24,1,0,1);
    SetRangeFontStyle(nPageTop+ARow,24,nPageTop+ARow,24,'常規(guī)','宋體',1,11);
    SetRangeHorizontalAlignment(nPageTop+ARow,24,nPageTop+ARow,24,xlCenter);
    SetRangeVerticalAlignment(nPageTop+ARow,24,nPageTop+ARow,24,xlCenter);
    //處理列
    for i := 0 to 9 do
    begin
      MergeCells(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5);
      SetRangeOutBorderStyle(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5,1,0,1);
      SetRangeFontStyle(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5,'常規(guī)','宋體',1,11);
      SetRangeHorizontalAlignment(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5,xlCenter);
      SetRangeVerticalAlignment(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5,xlCenter);
      nIndex := (APage-1)*AColNum+i+1;
      if nIndex <= AValueList.Count -1 then    //防止數(shù)據(jù)溢出
      begin
        case ARow of
          10: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.DJ;
          11: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.LJCD;
          13:
            begin
              sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.JCKY;
              SetRangeAutoWrap(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5);//自動換行
           end;
        end;
        if sValue <> '0' then
        begin
          Self.SetRangeValue(nPageTop+ARow,i*2+4,nPageTop+ARow,i*2+5,sValue);
        end;
      end;
    end;
    Exit;
  end;
  //普通情況
  for i := 0 to 10 do
  begin
    MergeCells(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4);
    SetRangeOutBorderStyle(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4,1,0,1);
    SetRangeFontStyle(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4,'常規(guī)','宋體',1,10);
    SetRangeHorizontalAlignment(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4,xlCenter);
    SetRangeVerticalAlignment(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4,xlCenter);
    nIndex := (APage-1)*AColNum + i;
    if nIndex <= AValueList.Count -1 then
    begin
      case ARow of
        5:
          begin
            sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.GH;

            if PRecData(Integer(AValueList.Objects[nIndex]))^.GG <> '' then
            begin
              dGanGao := StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.GG);
            end
            else begin
              dGanGao := 10;
            end;
            if i = 0 then
            begin
              if PRecData(Integer(AValueList.Objects[nIndex]))^.IsTJPole =1 then
              begin
                bIsTJPole := True;
                bIsFirstPole := True;
              end
              else begin
                bIsFirstPole := True;
                bIsTJPole := False;
              end;
            end
            else begin
              bIsFirstPole := False;
              bIsTJPole := False;
            end;
            if PRecData(Integer(AValueList.Objects[nIndex]))^.IsCable = 1 then
            begin
              bIsCable := True;   //是電纜
            end
            else begin
              bIsCable := False;   //不是電纜
            end;

            GetCellDMGanCoord(APage, i+1, dX1, dY1);
            //畫斷面圖
            CreateDMT( dX1, dY1, dGanGao, bIsTJPole, bIsFirstPole, bIsCable, dOldY2);

            //畫分支
            if PRecData(Integer(AValueList.Objects[nIndex]))^.FZ1ZJ <> '' then
            begin
              dAngle := StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ1ZJ);
              //畫分支
              GetCellGanCoord(APage, i+1, dX, dY);
              CreateFZLine(dX, dY,0,dAngle, PRecData(Integer(AValueList.Objects[nIndex]))^.FZ1MC);
            end;
            if PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ <> '' then
            begin
              GetCellGanCoord(APage, i+1, dX, dY);
              if dAngle >= 0 then
              begin
                if StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ)>=0 then
                begin
                  //畫分支 線路名同向
                  CreateFZLine(dX, dY, 14, StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ), PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2MC);
                end
                else begin
                  CreateFZLine(dX, dY,0, StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ), PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2MC);
                end;
              end
              else begin
                if StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ)<0 then
                begin
                  //畫分支 線路名同向
                  CreateFZLine(dX, dY, -14, StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ), PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2MC);
                end
                else begin
                  CreateFZLine(dX, dY,0, StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2ZJ), PRecData(Integer(AValueList.Objects[nIndex]))^.FZ2MC);                end;
              end;
            end;
          end;
        6:
          begin
            sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.GX;
            SetRangeAutoWrap(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4);//自動換行
          end;
        7: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.GG;
        8: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.MS;
        9: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.DXXH;
        12:
          begin
            Self.SetRangeFontStyle(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4,'常規(guī)','宋體',0,9);
            if PRecData(Integer(AValueList.Objects[nIndex]))^.ZJ <> '' then
            begin
              //畫轉(zhuǎn)角
              GetCellGanCoord(APage, i+1, dX, dY);
              CreateArrowheadLine(dX, dY, StrToFloat(PRecData(Integer(AValueList.Objects[nIndex]))^.ZJ));
            end;
            sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.ZJ;
            if sValue <> '' then
            begin
              sValue := DoubleToFenMiao(Abs(StrToFloat(sValue)));
            end;
          end;
        14: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.CZJL;
        15: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.HDGG;
        16: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.LXWZ;
        17: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.LXXHGS;
        18:
          begin
            sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.JYZXHSL;
            SetRangeAutoWrap(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4);//自動換行
          end;
        19: //變臺
          begin
            if i <> 0 then
            begin
              GetCellGanCoord(APage, i, dX1, dY1);   //上一個點坐標(biāo)
              GetCellGanCoord(APage, i+1, dX, dY);   //當(dāng)前點坐標(biāo)
              if PRecData(Integer(AValueList.Objects[nIndex]))^.BTXS <> '' then
              begin
                if PRecData(Integer(AValueList.Objects[nIndex-1]))^.BTXS <> '' then
                begin
                  //前一棵桿有變壓器
                  //畫線
                  Sheet.Shapes.AddLine(dX1+pm_BYQD-2, dY1, dX-pm_BYQD+2, dY).Select;
                end
                else begin
                  //前一棵桿無變壓器
                 Sheet.Shapes.AddLine(dX1, dY1, dX-pm_BYQD+2, dY).Select;
                end;
              end
              else begin
                if PRecData(Integer(AValueList.Objects[nIndex-1]))^.BTXS <> '' then
                begin
                  //畫線
                  Sheet.Shapes.AddLine(dX1+pm_BYQD-2, dY1, dX, dY).Select;
                end
                else begin
                  Sheet.Shapes.AddLine(dX1, dY1, dX, dY).Select;
                end;
              end;
              MyExcel.Selection.ShapeRange.ZOrder(msoSendToBack);
            end;
            if PRecData(Integer(AValueList.Objects[nIndex]))^.BTXS <> '' then
            begin
              //畫變臺
              GetCellGanCoord(APage, i+1, dX, dY);
              DrawBYQ(dX, dY);
              DrawBYQText(dX, dY, PRecData(Integer(AValueList.Objects[nIndex]))^.HM);
            end
            else begin
              //畫桿
              Sheet.Shapes.AddShape(msoShapeOval, pm_GanFirstLeft+(i*pm_GanOffset), (APage-1)*V_PageOffset+pm_GanTop, pm_GanD, pm_GanD);
            end;
            sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.BTXS;
          end;
        20: sValue := PRecData(Integer(AValueList.Objects[nIndex]))^.PBRL;
      end;
    end
    else begin
      //為了填補(bǔ)空格
      sValue := '';
    end;
    if sValue <> '' then
    begin
      SetRangeValue(nPageTop+ARow,i*2+3,nPageTop+ARow,i*2+4,sValue);//自動換行
    end;
  end;

end;

{
//功能描述:創(chuàng)建頁
//輸入?yún)?shù):APage       當(dāng)前頁號
            ABDZMC      變電站名稱
            AXLMC       線路名稱
            AValueList  要輸入的數(shù)據(jù)值列表
//輸出參數(shù):無
//創(chuàng)建時間:2006-04-14
//創(chuàng)建人:  趙占輕
}
procedure TExcel.CreatePage(APage: Integer;ABDZMC, AXLMC: String;AValueList: TStringList);
var
  sGDSMC: String;
  nColNum: Integer;
  sColName: String;
  nPageTop: Integer;
  AFontColor: TColor;
  nRow: Integer;
  i: Integer;
begin
  sGDSMC := '城關(guān)供電所';
  nColNum := 11;                   //字段列數(shù)
  nPageTop := (APage-1)*pm_PageRows;        //每頁行數(shù)
  AFontColor := 1;
  //處理第1行數(shù)據(jù)   標(biāo)題
  nRow := 1;
  SetRowHeight(nPageTop+nRow,20.25);
  //設(shè)定合并單元格
  MergeCells(nPageTop+nRow,1,nPageTop+nRow,24);
  SetRangeFontStyle(nPageTop+nRow,1,nPageTop+nRow,24,'粗體','宋體',AFontColor,16);  //設(shè)置指定區(qū)域中字體樣式
  SetRangeHorizontalAlignment(nPageTop+nRow,1,nPageTop+nRow,24,xlCenter);           //設(shè)置水平對齊方式
  SetRangeVerticalAlignment(nPageTop+nRow,1,nPageTop+nRow,24,xlCenter);             //設(shè)置垂直對齊方式
  SetRangeValue(nPageTop+nRow,1,nPageTop+nRow,24,pm_Title);                         //設(shè)置指定區(qū)域的值
  //處理第2行數(shù)據(jù)
  nRow := 2;
  SetRowHeight(nPageTop+nRow,23.25);
  //設(shè)定合并單元格
  MergeCells(nPageTop+nRow,1,nPageTop+nRow,2);
  SetRangeFontStyle(nPageTop+nRow,1,nPageTop+nRow,2,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,1,nPageTop+nRow,2,xlCenter);
  SetRangeVerticalAlignment(nPageTop+nRow,1,nPageTop+nRow,2,xlCenter);
  SetRangeValue(nPageTop+nRow,1,nPageTop+nRow,2,'線路名稱:');
  //
  MergeCells(nPageTop+nRow,3,nPageTop+nRow,6);
  SetRangeFontStyle(nPageTop+nRow,3,nPageTop+nRow,6,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,3,nPageTop+nRow,6,xlLeft);
  SetRangeVerticalAlignment(nPageTop+nRow,3,nPageTop+nRow,6,xlCenter);
  SetRangeValue(nPageTop+nRow,3,nPageTop+nRow,6,AXLMC);      //線路名稱

  MergeCells(nPageTop+nRow,7,nPageTop+nRow,8);
  SetRangeFontStyle(nPageTop+nRow,7,nPageTop+nRow,8,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,7,nPageTop+nRow,8,xlRight);
  SetRangeVerticalAlignment(nPageTop+nRow,7,nPageTop+nRow,8,xlCenter);
  SetRangeValue(nPageTop+nRow,7,nPageTop+nRow,8,'');      //'變電站名稱:';
  //
  MergeCells(nPageTop+nRow,9,nPageTop+nRow,14);
  SetRangeFontStyle(nPageTop+nRow,9,nPageTop+nRow,14,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,9,nPageTop+nRow,14,xlLeft);
  SetRangeVerticalAlignment(nPageTop+nRow,9,nPageTop+nRow,14,xlCenter);
  SetRangeValue(nPageTop+nRow,9,nPageTop+nRow,14,ABDZMC);      //賦變電站名稱

  MergeCells(nPageTop+nRow,21,nPageTop+nRow,23);
  SetRangeFontStyle(nPageTop+nRow,21,nPageTop+nRow,23,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,21,nPageTop+nRow,23,xlCenter);
  SetRangeVerticalAlignment(nPageTop+nRow,21,nPageTop+nRow,23,xlCenter);
  SetRangeValue(nPageTop+nRow,21,nPageTop+nRow,23,'');

  //處理第3行數(shù)據(jù)
  nRow := 3;
  SetRowHeight(nPageTop+nRow,100);
  MergeCells(nPageTop+nRow,1,nPageTop+nRow,2);
  SetRangeOutBorderStyle(nPageTop+nRow,1,nPageTop+nRow,2,1,1,1);
  SetRangeFontStyle(nPageTop+nRow,1,nPageTop+nRow,2,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,1,nPageTop+nRow,2,xlCenter);
  SetRangeVerticalAlignment(nPageTop+nRow,1,nPageTop+nRow,2,xlCenter);
  SetRangeValue(nPageTop+nRow,1,nPageTop+nRow,2,'斷  面  圖');

  MergeCells(nPageTop+nRow,3,nPageTop+nRow,24);
  SetRangeOutBorderStyle(nPageTop+nRow,3,nPageTop+nRow,24,1,1,1);
  SetRangeFontStyle(nPageTop+nRow,3,nPageTop+nRow,24,'常規(guī)','宋體',AFontColor,11);

  nRow := 4;
  SetRowHeight(nPageTop+nRow,69);

  MergeCells(nPageTop+nRow,1,nPageTop+nRow,2);
  SetRangeOutBorderStyle(nPageTop+nRow,1,nPageTop+nRow,2,1,1,1);
  SetRangeFontStyle(nPageTop+nRow,1,nPageTop+nRow,2,'常規(guī)','宋體',AFontColor,11);
  SetRangeHorizontalAlignment(nPageTop+nRow,1,nPageTop+nRow,2,xlCenter);
  SetRangeVerticalAlignment(nPageTop+nRow,1,nPageTop+nRow,2,xlCenter);
  SetRangeValue(nPageTop+nRow,1,nPageTop+nRow,2,'平  面  圖');

  MergeCells(nPageTop+nRow,3,nPageTop+nRow,24);
  SetRangeOutBorderStyle(nPageTop+nRow,3,nPageTop+nRow,24,1,1,1);
  SetRangeFontStyle(nPageTop+nRow,3,nPageTop+nRow,24,'常規(guī)','宋體',AFontColor,11);
  //InitShape(Sheet, APage);      //初始化圖
  //5
  nRow := nRow+1;
  sColName := '桿 號';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);

  //6
  nRow := nRow+1;
  sColName := '電桿種類及桿型';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  //7
  nRow := nRow+1;
  sColName := '桿高(米)';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  //8
  nRow := nRow+1;
  sColName := '埋深(米)';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);

  nRow := nRow+1;
  sColName := '導(dǎo)線型號';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);

  nRow := nRow+1;
  sColName := '檔距(米)';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '累計長度(米)';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '線路轉(zhuǎn)角';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '交叉跨越';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '垂直距離';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '橫擔(dān)規(guī)格';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '拉線位置';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '拉線型號/根數(shù)';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '絕緣子型號/數(shù)量';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '變臺型式';
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  sColName := '配變?nèi)萘?;
  FormatCells(APage, nColNum, nRow, sColName, AValueList);
  nRow := nRow+1;
  SetRowHeight(nPageTop+nRow,15);

  if V_PageOffset = 0 then
  begin
    //計算頁間距
    V_PageOffset := 0;
    for i := 1 to pm_PageRows do
    begin
      V_PageOffset := V_PageOffset + Sheet.Rows[i].RowHeight;
    end;
    V_PageOffset := V_PageOffset - 1;    //經(jīng)驗值
  end;
end;

{
功能描述:獲取指定范圍的值
輸入?yún)?shù):ABegRowNum: 指定范圍的起始行號
          ABegColNum:起始列號
          AEndRowNum:終止行號
          AEndColNum: 終止列號
輸出參數(shù):返回指定范圍的值
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function  TExcel.GetRangeValue(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):String;                    //獲取指定范圍的值
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    Result:=vRange.value;
  except
  end;
end;

{
功能描述:設(shè)置指定范圍的值
輸入?yún)?shù):ABegRowNum  指定范圍的起始行號
          ABegColNum  指定范圍的起始列號
          AEndRowNum  指定范圍的終止行號
          AEndColNum  指定范圍的終止列號
          AValue      待寫入指定范圍的值
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function  TExcel.SetRangeValue(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;AValue:string):Boolean;     //設(shè)置指定范圍的值
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    vRange.Value:=AValue;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定區(qū)域格式為自動換行
輸入?yún)?shù):ABegRowNum   指定的范圍的起始行號
          ABegColNum   指定的范圍的起始列號
          AEndRowNum   指定的范圍的終止行號
          AEndColNum   指定的范圍的終止列號
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetRangeAutoWrap(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):Boolean;  //設(shè)置指定區(qū)域格式為自動換行
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    vRange.WrapText := 1;                        //自動換行
    vRange.ShrinkToFit := False;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:取消指定區(qū)域的自動換行
輸入?yún)?shù):ABegRowNum  指定的范圍的起始行號
          ABegColNum  指定的范圍的起始列號
          AEndRowNum  指定的范圍的終止行號
          AEndColNum  指定的范圍的終止列號
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.CancelRangeAutoWrap(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer):Boolean;
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    vRange.WrapText := 0;                        //自動換行
    vRange.ShrinkToFit := True;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:    獲取指定頁,指定cell的斷面桿的中心坐標(biāo)
輸入?yún)?shù):    APage       當(dāng)前頁號
              ACellIndex  當(dāng)前單元格列號
輸出參數(shù):    無
輸入輸出參數(shù):AX  用于返回斷面桿的中心X坐標(biāo)
              AY  用于返回斷面桿的中心Y坐標(biāo)
創(chuàng)建時間:    2006-04-18
創(chuàng)建人:      趙占輕
}
procedure TExcel.GetCellDMGanCoord(APage, ACellIndex: Integer;var AX, AY: Double);
begin
  AX := pm_GanFirstLeft+((ACellIndex-1)*pm_GanOffset) + pm_GanD/2;
  AY := (APage-1)*V_PageOffset+dm_GanTop;
end;

{
功能描述:    創(chuàng)建斷面圖
輸入?yún)?shù):     AX1           桿塔底端X坐標(biāo)
              AY1           桿塔底端Y坐標(biāo)
              AGanGao       實際桿高
              AIsTJPole     是否T接桿
              AIsFirstPole  是否第一顆桿
              AIsCable      是否下電纜桿
輸出參數(shù):    無
輸入輸出參數(shù):AOldY2:返回桿塔的頂點Y坐標(biāo)
創(chuàng)建時間:     2006-04-18
創(chuàng)建人:      趙占輕

}
procedure TExcel.CreateDMT(AX1, AY1, AGanGao: Double;AIsTJPole, AIsFirstPole, AIsCable: Boolean;var AOldY2: Double);
//創(chuàng)建斷面圖
var
  AX2, AY2: Double;
  AShape: Variant;
  freBuilder: Variant;
begin
  AGanGao := GetPoleHight(AGanGao);  //計算圖上桿高
  AX2 := AX1;// + pm_GanOffset;
  AY2 := AY1 - dm_HaiBa - AGanGao;
  //斷面圖桿
  Sheet.Shapes.Addline(AX1, AY1 ,AX2, AY2);

  if not AIsFirstPole then
  begin
    if AIsCable then
    begin
      //斷面圖電纜
      AShape := Sheet.Shapes.AddLine(AX2, AY2, AX2-3, AY2);
      AShape.Line.DashStyle := 4;
      AShape := Sheet.Shapes.AddLine(AX2-3, AY2, AX2-3, AY2+AGanGao-3);
      AShape.Line.DashStyle := 4;
      AShape := Sheet.Shapes.AddLine(AX2-3, AY2+AGanGao-3, AX2-pm_GanOffset+3, AY2+AGanGao-3);
      AShape.Line.DashStyle := 4;
      AShape := Sheet.Shapes.AddLine(AX2-pm_GanOffset+3, AY2+AGanGao-3, AX2-pm_GanOffset+3, AOldY2);
      AShape.Line.DashStyle := 4;
      AShape := Sheet.Shapes.AddLine(AX2-pm_GanOffset+3, AOldY2, AX2-pm_GanOffset, AOldY2);
      AShape.Line.DashStyle := 4;
    end
    else begin
      //斷面圖導(dǎo)線
      freBuilder := Sheet.Shapes.BuildFreeform(msoEditingAuto, AX2, AY2);
      if AOldY2 - AY2 > dm_HuChui then
      begin
        freBuilder.AddNodes(msoSegmentCurve, msoEditingAuto, AX2-pm_GanOffset/2, AY2+(AOldY2-AY2)/2+dm_HuChui);
      end
      else begin
        freBuilder.AddNodes(msoSegmentCurve, msoEditingAuto, AX2-pm_GanOffset/2, AY2+dm_HuChui);
      end;
      freBuilder.AddNodes(msoSegmentCurve, msoEditingAuto, AX2-pm_GanOffset, AOldY2);
      freBuilder.ConvertToShape;
    end;
  end
  else begin
    if not AIsTJPole then
    begin
      //如果不是T接桿
      freBuilder := Sheet.Shapes.BuildFreeform(msoEditingAuto, AX2, AY2);
      freBuilder.AddNodes(msoSegmentCurve, msoEditingAuto, AX2-pm_GanOffset/4, AY2+(dm_HuChui*2/3));
      freBuilder.AddNodes(msoSegmentCurve, msoEditingAuto, AX2-pm_GanOffset/2, AY2+dm_HuChui);
      freBuilder.ConvertToShape;
    end;
  end;
  AOldY2 := AY2;
end;

{
功能描述:    獲取指定頁,指定cell的桿的中心坐標(biāo)
輸入?yún)?shù):    APage       當(dāng)前頁號
              ACellIndex  單元格列號
輸出參數(shù):    無
輸入輸出參數(shù):計算結(jié)構(gòu)存入AX,AY中
創(chuàng)建時間:    2006-04-18
創(chuàng)建人:      李志強(qiáng)
}
procedure TExcel.GetCellGanCoord(APage, ACellIndex: Integer;var AX, AY: Double);
begin
  AX := pm_GanFirstLeft+((ACellIndex-1)*pm_GanOffset) + pm_GanD/2;
  AY := (APage-1)*V_PageOffset+pm_GanTop + pm_GanD/2;
end;

{
功能描述:畫分支  創(chuàng)建轉(zhuǎn)角箭頭線
輸入?yún)?shù):AX             箭頭線起點X坐標(biāo)
          AY             箭頭線起點Y坐標(biāo)
          AYOffSet       文本框偏移量
          AAngle         箭頭線轉(zhuǎn)角
          AXLMC          分支名稱
輸出參數(shù):無
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
procedure TExcel.CreateFZLine(AX, AY,AYOffSet,AAngle: Double;AXLMC: String);
var
  vShape: Variant;
  dX2, dY2: Double;
  vSelection:Variant;
begin
  //角度向右為負(fù)  圖形顯示向下
  dX2 := AX + pm_Distance * Sin((90-AAngle)*Pi/180);
  dY2 := AY - pm_Distance * Cos((90-AAngle)*Pi/180);
  vShape := Sheet.Shapes.AddLine(AX, AY, dX2, dY2);
  //格式化箭頭線
  FormatArrowLineEndHead(vShape,msoArrowheadTriangle,msoArrowheadLengthMedium,msoArrowheadWidthMedium);
  FormatArrowLine(vShape,1.5,msoLineSingle,msoLineSolid);
  //插入文本框
  if AAngle < 0 then
  begin
    vSelection:=Sheet.Shapes.AddTextbox(msoTextOrientationHorizontal, AX-pm_GanOffset/2-5, AY+25+AYOffSet, 70, 11).Select;
  end
  else begin
    vSelection:=Sheet.Shapes.AddTextbox(msoTextOrientationHorizontal, AX-pm_GanOffset/2-5, AY-26+AYOffSet, 70, 11).Select;
  end;
  //格式化文本框
  SetTextBoxFillStyle(vSelection,msoFalse,0);         //設(shè)置文本框填充樣式
  SetTextBoxLineStyle(vSelection,msoFalse,0);         //設(shè)置文本框邊線樣式
  SetTextBoxFontStyle(vSelection,'宋體','常規(guī)',9,0);  //設(shè)置文本框字體樣式
  SetTextBoxText(vSelection,AXLMC);                   //設(shè)置文本框內(nèi)容
  SetTextBoxAlignment(vSelection,xlCenter,xlCenter);  //設(shè)置文本框?qū)R方式
end;

{
功能描述:創(chuàng)建轉(zhuǎn)角箭頭線
輸入?yún)?shù):AX      轉(zhuǎn)角箭頭線的起始X坐標(biāo)
          AY      轉(zhuǎn)角箭頭線的起始Y坐標(biāo)
          AAngle  轉(zhuǎn)角箭頭線的角度
輸出參數(shù):無
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
procedure TExcel.CreateArrowheadLine(AX, AY, AAngle: Double);
var
  vShape: Variant;
  dX2, dY2: Double;
begin
  //角度向右為負(fù)  圖形顯示向下
  dX2 := AX + pm_Distance * Sin((90-AAngle)*Pi/180);      //計算轉(zhuǎn)角箭頭線的終點X坐標(biāo)
  dY2 := AY - pm_Distance * Cos((90-AAngle)*Pi/180);      //計算轉(zhuǎn)角箭頭線的終點Y坐標(biāo)
  vShape := Sheet.Shapes.AddLine(AX, AY, dX2, dY2);       //繪制轉(zhuǎn)角箭頭線
  //下面設(shè)置箭頭線的樣式
  Self.FormatArrowLineEndHead(vShape,msoArrowheadTriangle,msoArrowheadLengthMedium,msoArrowheadWidthMedium);
end;

{
功能描述:雙精度的度轉(zhuǎn)換為度分秒
輸入?yún)?shù):雙精度的角度
輸出參數(shù):返回度分秒字符串
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.DoubleToFenMiao(Jiao:Double):string;
var
  TmpD:double;
  TmpI:integer;
  Str:string;
begin
  TmpI:=Trunc(Jiao);
  Str:=IntToStr(TmpI);
  TmpD:=Jiao-TmpI;
  TmpD:=TmpD*60;
  TmpI:=Trunc(TmpD);
  //Str:=Str+'度'+IntToStr(TmpI);
  Str:=Str+'°'+IntToStr(TmpI);
  TmpD:=TmpD-TmpI;
  TmpD:=TmpD*60;
  TmpI:=Trunc(TmpD);
  //Str:=Str+'分'+IntToStr(TmpI)+'秒';
  Str:=Str+'′'+IntToStr(TmpI)+'″';
  result:=Str;
end;

{
功能描述:繪制變壓器文本
輸入?yún)?shù):AX     文本X坐標(biāo)
          AY     文本Y坐標(biāo)
          AText  文本內(nèi)容
輸出參數(shù):無
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
procedure TExcel.DrawBYQText(AX, AY : Double;AText: String);
var
  vSelection:Variant;
begin
  vSelection:=InsertTextBox(AX-pm_GanOffset/2+1,AY+7,58,33,msoTextOrientationHorizontal);  //插入文本框
  SetTextBoxAlignment(vSelection,xlCenter,xlCenter);          //設(shè)置文本框?qū)R方式
  SetTextBoxFillStyle(vSelection,msoFalse,0);                 //設(shè)置文本框填充樣式
  SetTextBoxLineStyle(vSelection,msoFalse,0);                 //設(shè)置文本框邊線樣式
  SetTextBoxFontStyle(vSelection,'宋體','常規(guī)',9,0,);         //設(shè)置文本框的字體樣式
  Self.SetTextBoxText(vSelection,AText);                      //設(shè)置文本框內(nèi)容
end;

{
功能描述:繪制變壓器
輸入?yún)?shù):AX  初始X坐標(biāo)
          AY:初始Y坐標(biāo)
輸入?yún)?shù):無
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
procedure TExcel.DrawBYQ(AX, AY : Double);
var
  AX2, AY2: Double;
  AShape: Variant;
begin
  AY2 := AY + pm_BYQY;
  AX2 := AX - pm_GanD;
  AShape := Sheet.Shapes.AddShape(msoShapeOval, AX2, AY2, pm_BYQD, pm_BYQD);  //繪制左圈
  AShape.Fill.Visible := False;
  AX2 := AX-pm_GanD/3;
  AShape := Sheet.Shapes.AddShape(msoShapeOval, AX2, AY2, pm_BYQD, pm_BYQD);  //繪制右圈
  AShape.Fill.Visible := False;
end;

{
功能描述:設(shè)置指定行的行高
輸入?yún)?shù):ARowNum:     指定行的行號;
          ARowHeight:  目標(biāo)行高度值
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetRowHeight(ARowNum:Integer;ARowHeight:Double):Boolean;
begin
  try
    Sheet.Rows[ARowNum].RowHeight := ARowHeight;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:以15米桿高為標(biāo)準(zhǔn)計算d當(dāng)前桿塔圖形高度
輸入?yún)?shù):AHight:桿塔高度
輸出參數(shù):桿塔高度
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.GetPoleHight(AHight: Double): Double;
begin
  //已15米桿為標(biāo)準(zhǔn)
  Result := AHight*(80/15);
end;


{
功能描述:向指定工作表中插入圖片
輸入?yún)?shù):ABeginRow   圖片左上腳所處的單元格行號
          ABeginCol   圖片左上腳所處的單元格列號
          APicFile    要插入的圖片的全名
輸出參數(shù):插入成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function  TExcel.InsertPicIntoSheet(ABeginRow,ABeginCol:Integer;APicFile:String):Boolean;
var
  vBeginCell:Variant;
begin
  try
    vBeginCell:=Sheet.Cells[ABeginRow,ABeginCol];
    vBeginCell.Select;
    Sheet.Pictures.Insert(APicFile);
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定范圍的背景圖案
輸入?yún)?shù): ABegRowNum    指定的范圍的起始行號
          ABegColNum    指定的范圍的起始列號
          AEndRowNum    指定的范圍的終止行號
          AEndColNum    指定的范圍的終止列號
          APattern      圖案樣式
          APatternColor 圖案顏色
          ABackColor    背景顏色
          
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:   趙占輕
}
function TExcel.SetRangeBackGround(ABegRowNum,ABegColNum,AEndRowNum,AEndColNum:Integer;
         APattern:Integer=xlSolid;APatternColor:Integer=xlNone;ABackColor:Integer=xlNone):Boolean;
var
  vBegCell,vEndCell:Variant;
  vRange:Variant;
begin
  try
    vBegCell:=Sheet.Cells[ABegRowNum,ABegColNum];
    vEndCell:=Sheet.Cells[AEndRowNum,AEndColNum];
    vRange:=Sheet.Range[vBegCell,vEndCell];
    vRange.Interior.ColorIndex:=ABackColor;
    vRange.Interior.Pattern:=APattern;
    vRange.Interior.PatternColorIndex:=APatternColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:在指定位置插入文本框
輸入?yún)?shù):AX       文本框左上角X坐標(biāo)
          AY       文本框左上角Y坐標(biāo)
          AWidth   文本框?qū)?br>          AHeight  文本框高
          AAlign   文本框中文本方向
                   (xlHorizontal 文字字頭朝上 橫向排列
                    xlVertical   文字字頭朝上 豎向排列
                    xlUpward     文字字頭朝右 橫向排列
                    xlDownward   文字字頭朝左 橫向排列
                   )
輸出參數(shù):執(zhí)行成功返回插入的文本框
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.InsertTextBox(AX,AY,AWidth,AHeight:Double;AOrient:Integer=msoTextOrientationHorizontalRotatedFarEast):Variant;
begin
  try
    Sheet.Shapes.AddTextbox(AOrient,AX, AY,AWidth,AHeight).Select;
    Result:=MyExcel.selection;//加入文本框
  except
  end;
end;

{
功能描述:設(shè)置文本框填充樣式
輸入?yún)?shù):ATextBox       指定的文本框
          AVisible       文本框是否顯示填充樣式
          ATransparency  透明程度
                     0: 不透明
                     0.5 半透明
                     1   透明

輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetTextBoxFillStyle(ATextBox:Variant;AVisible:Integer;ATransparency:Double=0):Boolean;
begin
  try
    ATextBox.ShapeRange.Fill.Visible := AVisible;
    ATextBox.ShapeRange.Fill.Transparency := ATransparency;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置文本框邊框樣式
輸入?yún)?shù):ATextBox:      指定文本框;
          AVisible:     邊框是否可見;
          ATransparency:透明程度
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetTextBoxLineStyle(ATextBox:Variant;AVisible:Integer;ATransparency:Double=0):Boolean;
begin
  try
    ATextBox.ShapeRange.Line.Transparency := ATransparency;
    ATextBox.ShapeRange.Line.Visible := AVisible;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置文本框中文字內(nèi)容
輸入?yún)?shù):ATextBox: 指定文本框
          AText:   內(nèi)容字符串
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetTextBoxText(ATextBox:Variant;AText:string):Boolean;
begin
  try
    ATextBox.Characters.Text := AText;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置文本框中字體樣式
輸入?yún)?shù):ATextBox:     指定文本框;
          AFontName:   字體名稱;
          AFontStyle:   字體樣式;
          AFontSize:   字體大小
          AFontColor:   字體顏色
          
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetTextBoxFontStyle(ATextBox:Variant;AFontName,AFontStyle:String;AFontSize:Integer=12;AFontColor:Integer=0):Boolean;
begin
  try
    //設(shè)置文本框樣式
    ATextBox.Font.Name := '宋體';
    ATextBox.Font.Size := AFontSize;
    ATextBox.Font.ColorIndex:=AFontColor;                 //設(shè)置字體顏色
    ATextBox.Font.FontStyle:=AFontStyle;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置文本框水平和垂直對齊方式
輸入?yún)?shù):ATextBox:    指定文本框
          HAlign:     水平對齊方式;(xlCenter 居中 ;xlLeft 靠左;xlRight 靠右;xlJustify 兩端對齊)
          VAlign:     垂直對齊方式  (xlCenter 居中 ;xlTop 靠左;xlBottom 靠右;xlJustify 兩端對齊)
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.SetTextBoxAlignment(ATextBox:Variant;HAlign:Integer=xlLeft;VAlign:Integer=xlBottom):Boolean;
begin
  try
    ATextBox.HorizontalAlignment := HAlign;
    ATextBox.VerticalAlignment := VAlign;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:格式化箭頭線的末端樣式
輸入?yún)?shù):ALine        待格式化的箭頭線
          AheadStyle   末端樣式
          AheadLength  末端長
          AheadWidth   末端寬
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.FormatArrowLineEndHead(ALine:Variant;AheadStyle:Integer=msoArrowheadTriangle;
             AheadLength:Integer=msoArrowheadLengthMedium;AheadWidth:Integer=msoArrowheadWidthMedium):Boolean;
begin
  try
    ALine.Line.EndArrowheadLength := AheadLength;
    ALine.Line.EndArrowheadWidth := AheadWidth;
    ALine.Line.EndArrowheadStyle := AheadStyle;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:格式化箭頭線的首端樣式
輸入?yún)?shù):ALine        待格式化的箭頭線
          AheadStyle   首端樣式
          AheadLength  首端長
          AheadWidth   首端寬
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.FormatArrowLineBeginHead(ALine:Variant;AheadStyle:Integer=msoArrowheadTriangle;
             AheadLength:Integer=msoArrowheadLengthMedium;AheadWidth:Integer=msoArrowheadWidthMedium):Boolean;
begin
  try
    ALine.Line.BeginArrowheadLength := AheadLength;
    ALine.Line.BeginArrowheadWidth := AheadWidth;
    ALine.Line.BeginArrowheadStyle := AheadStyle;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:格式化箭頭線的線樣式
輸入?yún)?shù):ALine        待格式化的箭頭線
          AWidth       線寬
          AStyle       線樣式
          ADashStyle   虛線樣式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-17
創(chuàng)建人:  趙占輕
}
function TExcel.FormatArrowLine(ALine:Variant;AWidth:Double=1.5;AStyle:Integer=msoLineSingle;ADashStyle:Integer=msoLineSolid):Boolean;
begin
  try
    ALine.Line.Weight := AWidth;
    ALine.Line.DashStyle := ADashStyle;
    ALine.Line.Style := AStyle;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置當(dāng)前窗口網(wǎng)格的顯示與否
輸入?yún)?shù):IsVisible:控制網(wǎng)格顯示的參數(shù)
              (True:顯示網(wǎng)格;False:隱藏網(wǎng)格)
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-05-07
創(chuàng)建人:  趙占輕
}
function TExcel.SetActiveWindowGridVisible(IsVisible:Boolean=True):Boolean;        //設(shè)置當(dāng)前窗口網(wǎng)格的顯示與否
begin
  Result:=False;
  try
    MyExcel.Application.ActiveWindow.DisplayGridlines:=IsVisible;
  except
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定行的字體樣式
輸入?yún)?shù):ARowNum:  待設(shè)置的行的行號
          AFontStyle:目標(biāo)字體樣式(如粗體);
          AFontName: 目標(biāo)字體名稱;
          AFontColor 目標(biāo)字體顏色
          AFontSize: 目標(biāo)字體大小
輸出參數(shù):執(zhí)行成功返回真;否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕
}
function  TExcel.SetRowFontStyle(ARowNum:Integer;AFontStyle:string='常規(guī)';AFontName:string='宋體';
                                AFontColor:Integer=0;AFontSize:Integer=12):Boolean;
var
  vRange:Variant;
begin
  try
    vRange:=Sheet.Rows[ARowNum];
    vRange.Font.ColorIndex:=AFontColor;                 //設(shè)置字體顏色
    vRange.Font.Name:=AFontName;                        //設(shè)置字體名稱
    vRange.Font.Size:=AFontSize;                        //設(shè)置字體大小
    vRange.Font.FontStyle:=AFontStyle;                  //設(shè)置字體樣式
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定列的字體樣式
輸入?yún)?shù):AColNum:     待設(shè)置的列的列號
          AFontStyle:   目標(biāo)字體樣式(如粗體);
          AFontName:    目標(biāo)字體名稱;
          AFontColor:   目標(biāo)字體顏色
          AFontSize:    目標(biāo)字體大小
輸出參數(shù):執(zhí)行成功返回真;否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕
}
function  TExcel.SetColumnFontStyle(AColNum:Integer;AFontStyle:string='常規(guī)';AFontName:string='宋體';
                                 AFontColor:Integer=0;AFontSize:Integer=12):Boolean;        //設(shè)置指定列的字體樣式
var
  vRange:Variant;
begin
  try
    vRange:=Sheet.Columns[AColNum];
    vRange.Font.ColorIndex:=AFontColor;                 //設(shè)置字體顏色
    vRange.Font.Name:=AFontName;                        //設(shè)置字體名稱
    vRange.Font.Size:=AFontSize;                        //設(shè)置字體大小
    vRange.Font.FontStyle:=AFontStyle;                  //設(shè)置字體樣式
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定行的外邊框樣式
輸入?yún)?shù):ARowNum     待設(shè)置行的行號
          AWeight     邊線粗度
          ALineColor  邊線顏色
          ALineStyle  邊線樣式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕
}
function TExcel.SetRowOutBorderStyle(ARowNum:Integer;AWeight:Integer=2;
                                 ALineColor:Integer=0;ALineStyle:Integer=xlContinuous):Boolean;        //設(shè)置指定行的外邊框樣式
var
  vRange:Variant;
begin
  vRange:=Sheet.Rows[ARowNum];
  try
    //設(shè)置左邊框
    vRange.Borders.Item[xlEdgeLeft].LineStyle :=ALineStyle;
    vRange.Borders.Item[xlEdgeLeft].Weight := AWeight;
    vRange.Borders.Item[xlEdgeLeft].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置頂邊框
    vRange.Borders.Item[xlEdgeTop].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeTop].Weight := AWeight;
    vRange.Borders.Item[xlEdgeTop].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置底邊框
    vRange.Borders.Item[xlEdgeBottom].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeBottom].Weight := AWeight;
    vRange.Borders.Item[xlEdgeBottom].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置右邊框
    vRange.Borders.Item[xlEdgeRight].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeRight].Weight := AWeight;
    vRange.Borders.Item[xlEdgeRight].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定列的外邊框樣式
輸入?yún)?shù):AColNum      待設(shè)置列的列號
          AWeight      邊線粗度
          ALineColor   邊線顏色
          ALineStyle   邊線樣式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕
}
function TExcel.SetColumnOutBorderStyle(AColNum:Integer;AWeight:Integer=2;ALineColor:Integer=0;        //設(shè)置指定列的外邊框樣式
                                ALineStyle:Integer=xlContinuous):Boolean;
var
  vRange:Variant;
begin
  vRange:=Sheet.Columns[AColNum];
  try
    //設(shè)置左邊框
    vRange.Borders.Item[xlEdgeLeft].LineStyle :=ALineStyle;
    vRange.Borders.Item[xlEdgeLeft].Weight := AWeight;
    vRange.Borders.Item[xlEdgeLeft].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置頂邊框
    vRange.Borders.Item[xlEdgeTop].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeTop].Weight := AWeight;
    vRange.Borders.Item[xlEdgeTop].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置底邊框
    vRange.Borders.Item[xlEdgeBottom].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeBottom].Weight := AWeight;
    vRange.Borders.Item[xlEdgeBottom].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置右邊框
    vRange.Borders.Item[xlEdgeRight].LineStyle := ALineStyle;
    vRange.Borders.Item[xlEdgeRight].Weight := AWeight;
    vRange.Borders.Item[xlEdgeRight].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定行的分隔線樣式
輸入?yún)?shù):ARowNum    待設(shè)置的行號
          AWeight    分割線粗度
          ALineColor 分割線顏色
          ALineStyle 分割線樣式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕
}
function TExcel.SetRowInnerLineStyle(ARowNum:Integer;AWeight:Integer=2;ALineColor:Integer=0;        //設(shè)置指定行的分隔線樣式
                                ALineStyle:Integer=xlContinuous):Boolean;
var
  vRange:Variant;
begin
  vRange:=Sheet.Rows[ARowNum];
  try
    //設(shè)置垂直線樣式
    vRange.Borders.Item[xlInsideVertical].LineStyle :=ALineStyle;
    vRange.Borders.Item[xlInsideVertical].Weight := AWeight;
    vRange.Borders.Item[xlInsideVertical].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置水平線樣式
    vRange.Borders.Item[xlInsideHorizontal].LineStyle := ALineStyle;
    vRange.Borders.Item[xlInsideHorizontal].Weight := AWeight;
    vRange.Borders.Item[xlInsideHorizontal].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;
{
功能描述:設(shè)置指定列的分隔線樣式
輸入?yún)?shù):AColNum     待設(shè)置的列號
          AWeight     分割線粗度
          ALineColor  分割線顏色
          ALineStyle  分割線樣式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-05-08
創(chuàng)建人:  趙占輕

}
function TExcel.SetColumnInnerLineStyle(AColNum:Integer;AWeight:Integer=2;ALineColor:Integer=0;        //設(shè)置指定列的分隔線樣式
                                ALineStyle:Integer=1):Boolean;
var
  vRange:Variant;
begin
  vRange:=Sheet.Columns[AColNum];
  try
    //設(shè)置垂直線樣式
    vRange.Borders.Item[xlInsideVertical].LineStyle :=ALineStyle;
    vRange.Borders.Item[xlInsideVertical].Weight := AWeight;
    vRange.Borders.Item[xlInsideVertical].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  try
    //設(shè)置水平線樣式
    vRange.Borders.Item[xlInsideHorizontal].LineStyle := ALineStyle;
    vRange.Borders.Item[xlInsideHorizontal].Weight := AWeight;
    vRange.Borders.Item[xlInsideHorizontal].ColorIndex := ALineColor;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定行的水平對其方式
輸入?yún)?shù):ARowNum   待設(shè)置的列號
          AAlign    對其方式  常用值:
                   xlCenter 居中
                   xlLeft 靠左
                   xlRight 靠右
                   xlJustify 兩端對齊
                  
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}

function  TExcel.SetRowHorizontalAlignment(ARowNum:Integer;AAlign:Integer=xlLeft):Boolean;  
var
  vRange:Variant;
begin
  try
    vRange:=Sheet.Rows[ARowNum];
    vRange.HorizontalAlignment:= AAlign;   
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定行的垂直對其方式
輸入?yún)?shù):ARowNum  待設(shè)置的行號
          AAlign   對其方式  常用值
                    xlCenter居中
                    xlTop 靠左
                    xlBottom 靠右
                    xlJustify 兩端對齊

輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}

function  TExcel.SetRowVerticalAlignment(ARowNum:Integer;AAlign:Integer=xlBottom):Boolean;           //設(shè)置指定行的垂直平對其方式
var
  vRange:Variant;
begin
  try
    vRange:=Sheet.Rows[ARowNum];
    vRange.VerticalAlignment:= AAlign;   
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定列的水平對其方式
輸入?yún)?shù):AColNum  待設(shè)置的列號
          AAlign   對其方式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}

function  TExcel.SetColumnHorizontalAlignment(AColNum:Integer;AAlign:Integer=xlLeft):Boolean;  //設(shè)置指定列的水平對其方式
var
  vRange:Variant;
begin
  try
    vRange:=Sheet.Columns[AColNum];
    vRange.HorizontalAlignment:= AAlign;  
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:設(shè)置指定列的垂直對其方式
輸入?yún)?shù):AColNum: 待設(shè)置的列號;AAlign:對其方式
輸出參數(shù):執(zhí)行成功返回真否則返回假
創(chuàng)建時間:2006-04-13
創(chuàng)建人:  趙占輕
}
function  TExcel.SetColumnVerticalAlignment(AColNum:Integer;AAlign:Integer=xlBottom):Boolean;
var
  vRange:Variant;
begin
  try
    vRange:=Sheet.Columns[AColNum];
    vRange.VerticalAlignment:= AAlign;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;

{
功能描述:Excel數(shù)據(jù)保存到文件
輸入?yún)?shù):AFileName:待保存的文件全名
輸出參數(shù):保存成功返回真否則返回假
創(chuàng)建時間:2006-05-30
創(chuàng)建人:  趙占輕
}
function  TExcel.SaveToFile(AFileName:string):Boolean;              //Excel數(shù)據(jù)保存到文件
begin
  try
    if FileExists(AFileName) then
    begin
      if DeleteFile(AFileName) then
      begin
        MyExcel.ActiveWorkbook.saveAs(AFileName);
      end else
      begin
        Result:=False;
        Exit;
      end;
    end else
    begin
      MyExcel.ActiveWorkbook.saveAs(AFileName);
    end;
  except
    Result:=False;
    Exit;
  end;
  Result:=True;
end;


end.//This Unit is over;
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
cxGrid V6以上導(dǎo)出EXCEL的方法
RunDll
VBA函數(shù)參考
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服