• TXLSReadWriteII 公式计算


    unit Unit1;
    
     
    
    interface
    
     
    
    uses
    
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    
      Dialogs, XLSReadWriteII2, StdCtrls, XLSUtils2;
    
     
    
    type
    
      TForm1 = class(TForm)
    
        aXlsObj: TXLSReadWriteII2;
    
        Button1: TButton;
    
        aSaveDialog: TSaveDialog;
    
        procedure Button1Click(Sender: TObject);
    
      private
    
        { Private declarations }
    
      public
    
        { Public declarations }
    
      end;
    
     
    
    var
    
      Form1: TForm1;
    
     
    
    implementation
    
     
    
    {$R *.dfm}
    
     
    
    procedure TForm1.Button1Click(Sender: TObject);
    
    var
    
      i, j: Integer;
    
      aFileName, aStampTime: AnsiString;
    
      aa: TFormulaValue;
    
    begin
    
      try
    
        aSaveDialog.InitialDir := ExtractFilePath(ParamStr(0));
    
        aSaveDialog.DefaultExt := 'xls';
    
        aSaveDialog.Filter := 'Excel文件(*.xls)|*.xls';
    
        aStampTime := FormatDateTime('yyyymmddhhnnss', Now);
    
        aSaveDialog.FileName := aStampTime;
    
     
    
        if not aSaveDialog.Execute then
    
          Exit;
    
     
    
        aFileName := aSaveDialog.FileName;
    
        if aFileName = '' then
    
          Exit;
    
      finally
    
     
    
      end;
    
     
    
      try
    
        aXlsObj.Sheets[0].AsWideString[0, 0] := 'id';
    
        aXlsObj.Sheets[0].AsWideString[1, 0] := 'formula';
    
        aXlsObj.Sheets[0].AsWideString[2, 0] := 'lie1';
    
        aXlsObj.Sheets[0].AsWideString[3, 0] := 'lie2';
    
        for i:=1 to 10 do
    
        begin
    
          aXlsObj.Sheets[0].AsWideString[0, i] := Format('%d', [i+1]);
    
          aXlsObj.Sheets[0].AsFormula[1, i] := Format('C%d + D%d', [i+1, i+1]);
    
          aXlsObj.Sheets[0].AsFloat[2, i] := ( i * 5);
    
          aXlsObj.Sheets[0].AsFloat[3, i] := ( i * 4);
    
        end;
    
        for i:=1 to 10 do
    
        begin
    
          aa := aXlsObj.Sheets[0].AsFormulaValue[1 ,i];
    
          case aa.ValType of
    
            fvFloat:   ShowMessage(FloatToStr(aa.vFloat));
    
          end;
    
        end;
    
     
    
        aXlsObj.Filename := aFileName;
    
        aXlsObj.Write;
    
        ShowMessage(Format('导出文件'+#13#10+'%s'+#13#10 +'成功!', [aFileName]));
    
      finally
    
      end;
    
     
    
    end;
    
     
    
    end.
    

      

  • 相关阅读:
    Bellman-Ford 单源最短路径算法
    Prim 最小生成树算法
    Kruskal 最小生成树算法
    Kosaraju 算法检测有向图的强连通性
    Kosaraju 算法查找强连通分支
    不相交集合森林的启发式策略
    Union-Find 检测无向图有无环路算法
    redis的持久化方式RDB和AOF的区别
    Docker -v 对挂载的目录没有权限 Permission denied
    postgresql如何让主键自增
  • 原文地址:https://www.cnblogs.com/yzryc/p/7676303.html
Copyright © 2020-2023  润新知