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.

  

TXLSReadWriteII 公式计算的更多相关文章

  1. 用python实现计算1-2*((60-30+(-40/5)*(9-2*5/3+7/3*99/4*2998+10*568/14))-(-4*3)/(16-3*2))类似的公式计算

    作业需求: 开发一个简单的python计算器 1.实现加减乘除及拓号优先级解析 2.用户输入 1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 ...

  2. WPF实现强大的动态公式计算

    数据库可以定义表不同列之间的计算公式,进行自动公式计算,但如何实现行上的动态公式计算呢?行由于可以动态扩展,在某些应用场景下将能很好的解决实际问题. 1.VS2012新建一个WPF应用程序WpfApp ...

  3. 使用Machin公式计算

    使用Machin公式计算,并使用百亿进制+末项位数控制,这里可算出数万位(比最简PI快80倍),源代码约40行,在本网页中. 计算公式 PI=16arctg(1/5)-4arctg(1/239),其中 ...

  4. c语言详解  蔡勒(Zeller)公式计算某一天是星期几  极其方便

    —— 蔡勒(Zeller)公式 ,小于等于14,即在蔡勒公式中,某年的1.2月要看作上一年的13.14月来计算,比如2003年1月1日要看作2002年的13月1日来计算):d:日:[ ]代表取整,即只 ...

  5. Windows API方式直接调用C#的DLL,支持多音字转拼音、Gzip解压缩、公式计算(VBA、C++、VB、Delphi甚至java都可以)

    原始链接 https://www.cnblogs.com/Charltsing/p/DllExport.html 这两年,我在VBA应用方面一直有几大痛点:1.多音字转拼音:2.64位下的GZIP解压 ...

  6. Codeforces Round #532 (Div. 2)- C(公式计算)

    NN is an experienced internet user and that means he spends a lot of time on the social media. Once ...

  7. 【Zeller公式计算星期几】HDU 6112 今夕何夕

    acm.hdu.edu.cn/showproblem.php?pid=6112 [思路] 公式计算即可,注意特判2月29号 Zeller公式里,计算出的week不能直接模7,要保证week是正数 [A ...

  8. C语言:根据以下公式计算s,s=1+1/(1+2)+1/(1+2+3)+...+1/(1+2+3+...+n) -在形参s所指字符串中寻找与参数c相同的字符,并在其后插入一个与之相同的字符,

    //根据一下公式计算s,并将计算结果作为函数返回值,n通过形参传入.s=1+1/(1+2)+1/(1+2+3)+...+1/(1+2+3+...+n) #include <stdio.h> ...

  9. SpreadJS + GcExcel 一出,谁与争锋!全栈表格技术轻松应对复杂公式计算场景(一)

    设计思路篇 Excel是我们日常办公中最常用的电子表格程序,不仅可满足报表数据的计算需求,还可提供绘图.数据透视分析.BI和Visual Basic for Applications (VBA)宏语言 ...

随机推荐

  1. Windows10 VS2017 C++使用crypto++库加密解密(AES)

    参考文章: https://blog.csdn.net/tangcaijun/article/details/42110319 首先下载库: https://www.cryptopp.com/#dow ...

  2. js实现颜色渐变

    #grad { background: -webkit-linear-gradient(red, blue); /* Safari 5.1 - 6.0 */ background: -o-linear ...

  3. linux 创建sudo账号.md

    内容来源自网络 方案一 root登录 ssh root@server_ip_address 新增用户 adduser username 设置密码 passwd username 输入两次密码 修改帐户 ...

  4. InstallShield-常用prq文件的下载地址

    VC 2010 redist X86: http://saturn.installshield.com/is/prerequisites/microsoft visual c++ 2010 redis ...

  5. SQLI DUMB SERIES-7

    (1)查看PHP源代码 可以看见输入的id被一对单引号和两对圆括号包围 (2)根据提示:Dump into Outfile可知,此次攻击需要导出文件 (3)在第一关获取 @@datadir 读取数据库 ...

  6. split用法

    例1:基本的分割split() var str="How are you doing today?" var a=str.split(" ")//分别输出5个单 ...

  7. 学习笔记TF038:实现估值网络

    Q-Learning,学习Action对应期望值(Expected Utility).1989年,Watkins提出.收敛性,1992年,Watkins和Dayan共同证明.学习期望价值,从当前一步到 ...

  8. PythonStudy——函数的导入 Import of functions

    # 函数:完成 特定 功能的代码块,作为一个整体,对其进行特定的命名,该名字就代表函数# 难点:如何定义个函数 # 现实中很多问题要通过一些工具进行处理 => 可以将工具提前生产出来并命名# = ...

  9. centos7怎么查看、打开和关闭防火墙

    使用centos7会发现,用centos6以前的方式查看.打开和关闭防火墙都无效了.这是因为centos7的防火墙改用firewalld,而不再使用iptables了 查看centos7的防火墙的状态 ...

  10. 各CF-based tracker中output_sigma_factor取值

    现有的各CF-Based tracker中理想高斯响应中output_sigma_factor的取值情况 默认output_sigma = target_sz*output_sigma_factor; ...