unigui导出TMS.Flexcel【5】
参考代码
procedure TUniFrmeWebEmbedBase.ExportData;
//导出到excel
var
FlexCelImport1: TExcelFile;
i, rowindex, colindex: Integer;
ms : TMemoryStream;
begin
{ 检查数据集 }
if Assigned(cdsMain) and cdsMain.Active then
try
{ 创建Excel文件 }
FlexCelImport1 := TXlsFile.Create(true);//NewFile(1);
FlexCelImport1.NewFile(); // FlexCelImport1.SupportsXlsx := True;
// FlexCelImport1.NewFile(WorkSheetCount, TExcelFileFormat(2) ); //2 = v2010, 1 = v2007, 0 = v2003
// FlexCelImport1.ActiveSheet := 1; cdsMain.First;
{ 第一行为标题 }
rowindex := ;
colindex := ;
for i := to cdsMain.FieldCount - do
{ 只导出数据集中可视的字段 }
if cdsMain.Fields[i].Visible then
begin
FlexCelImport1.SetCellValue(rowindex, colindex,cdsMain.Fields[i].DisplayLabel);
inc(colindex);
end;
{ 依次导出数据 }
while not cdsMain.Eof do
begin
{ 增加一行 }
inc(rowindex);
colindex := ;
for i := to cdsMain.FieldCount - do
{ 只导出数据集中可视的字段 }
if cdsMain.Fields[i].Visible then
begin
{ 时间和日期字段需要单独出来一下,否则出来的都是浮点数 }
if cdsMain.Fields[i].DataType in [ftDate, ftDateTime, ftTime, ftTimeStamp] then
FlexCelImport1.SetCellValue(rowindex, colindex, cdsMain.Fields[i].AsString)
else
FlexCelImport1.SetCellValue(rowindex, colindex, cdsMain.Fields[i].Value);
inc(colindex);
end;
{ 下一条 }
cdsMain.Next;
end;
FlexCelImport1.PrintLandscape := true;
// FlexCelImport1.
{ 创建内存流 }
ms := TMemoryStream.Create;
try
{ 将Excel保存到内存流 }
FlexCelImport1.save(ms);
ms.Position := ;
{ 将数据流发送到客户端,同时指定下载文件名,非常简单 }
UniSession.SendStream(ms, 'usegear.xls' );
finally
ms.Free;
{ 清理内存 }
FlexCelImport1.Free;
end;
except
on E : Exception do
FlexCelImport1.Free;
end;
end; 参考:
http://forums.unigui.com/index.php?/topic/4197-unigrid-dataset-to-xlsx-export-using-tms-flexcel-an-example/?hl=excel https://www.cnblogs.com/ChinaEHR/p/4012113.html
一并感谢。
调用
procedure TUniFrmeWebEmbedBase_authoManage.act_ExportExecute(Sender: TObject);
begin
cdsMain.Data := Unit_dm.DataModule1.getTabeldata('select * from SM_role') ;
inherited;
end;
效果
这里
TUniFrmeWebEmbedBase_authoManage = class(TUniFrmeWebEmbedBase)
TUniFrmeWebEmbedBase = class(TUniFrame)
unigui导出TMS.Flexcel【5】的更多相关文章
- unigui导出EXCEL使用NATIVEEXCEL
unigui导出EXCEL使用NATIVEEXCEL // 需要nativeexcel控件// cxg 2017-9-9 unit myExcel; interface uses System.Sys ...
- uniGUI试用笔记(七)
uniGUI的文件下载由于TUniSession的存在而变得非常简单,最典型的一个例子就是将列表中的所有数据导出到Excel中.服务器上采用TMS FlexCel控件,先将数据集中的记录导入到Exce ...
- uniGUI试用笔记(六)
uniGUI提供了一个文件上传控件TUniFileUpload,进行数据的导入就变得比较容易.首先将TUniFileUpload控件放置在窗体上,按下导入按钮后,执行TUniFileUpload的文件 ...
- C# 7个读写Excel文件的类库
转载自:http://www.cnblogs.com/wintersun/archive/2013/02/26/2933294.html 有时我们在项目需要操作Excel文件,读或写,导出数据等. ...
- 13 Amazing Component Sets Driving Success In Delphi Berlin On Android And IOS
There are quite a few Firemonkey component sets available for Delphi Berlin which can get you ahead ...
- unigui 导入导出数据
导入:首先要用TUniFileUpload将文件从客户端上传至服务端,然后完成导入. TUniFileUpload上传文件的演示代码: UniFileUpload1.Execute; UniFileU ...
- 基于uniGui开发的Delphi后台管理框架uniFramework
uniGui是基于Delphi的一套开发Web应用的UI框架,前端使用的是ExtJS,最新版的uniGUI1.5 1480已支持新版的ExtJS6.5.3.我认为uniGUI是目前Delphi下最完善 ...
- unigui+fastReport实现web打印方案
近日单位需要用到会议通知单的打印功能,故引出篇. unigui是delphi环境下快速开发web应用的优秀工具,不再赘述,下面直接记录使用搭配使用,基本逻辑就是: unigui实现数据录入和浏览的we ...
- unigui+fastreport报表打印
unigui+fastreport报表打印 unigui+fastreport报表打印 FASTREPORT导出成PDF报表,UNIGUI的TUniURLFrame显示PDF报表并打印. func ...
随机推荐
- emma中文显示乱码问题解决
在Linux中如果使用mysql的图形客户端,个人感觉Emma还不错.但是emma默认用apt-get 安装的话,emma是不支持中文的,这个需要自己修改一下了配置文件,或者直接修改emma程序源文件 ...
- 转贴:获取元素CSS值之getComputedStyle方法熟悉
获取元素CSS值之getComputedStyle方法熟悉 一.碎碎念~前言 我们都用过jQuery的CSS()方法,其底层运作就应用了getComputedStyle以及getPropertyVal ...
- 理解C#泛型(转)
理解C#泛型 http://www.cnblogs.com/wilber2013/p/4292240.html 泛型中的类型约束和类型推断 http://www.cnblogs.com/wilber2 ...
- Google C++编程规范 – 第十九条 -《前置声明》
转自:http://roclinux.cn/?p=3285 本原创文章属于<Linux大棚>博客. 博客地址为http://roclinux.cn. 文章作者为roc wu == [规范] ...
- SQL Server 添加描述
添加描述的格式 exec sys.sp_addextendedproperty @name = N'MS_Description' ,@value = 'value',@level0type=N'SC ...
- js的多种数值分类相加,数据先后没有顺序,不确定同类数据多少
下面是js源码片段.看的是思想. <script type="text/javascript"> deg_countMyChart = function(deptcod ...
- bzoj 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘【凸包】
凸包模板 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> ...
- [Swift]经典解题思路:联合查找Union Find
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- [App Store Connect帮助]三、管理 App 和版本(6.3)转让 App:发起 App 转让
在发起前,您需要接收者组织中“帐户持有人”的 Apple ID,并且满足 App 转让的条件.请前往 App 转让条件. 注:App 转让完成后,该 App 会从您的帐户中移除,因此,您应当备份该 A ...
- BFS HDOJ 1728 逃离迷宫
题目传送门 /* BFS:三维BFS,加上方向.用dp[x][y][d]记录当前需要的最少转向数 */ #include <cstdio> #include <algorithm&g ...