zoukankan
html css js c++ java
stringgrid to execl
NativeExcel
procedure Tsave.CopySGDataToExcel(Target: TStringGrid;FileName: string);
var
iCount, jCount: Integer;
XLApp: Variant;
Sheet: Variant;
begin
Screen.Cursor := crHourGlass;
if not VarIsEmpty(XLApp) then
begin
XLApp.DisplayAlerts := False;
XLApp.Quit;
VarClear(XLApp);
end;
//通过ole创建Excel对象
try
XLApp := CreateOleObject('Excel.Application');
except
Screen.Cursor := crDefault;
Exit;
end;
SaveDialog1.DefaultExt := 'xls';
SaveDialog1.FileName := FileName;XLApp.WorkBooks.Add; //你要把数据放在那里啊,先生成个文件在e:1.xls
XLApp.WorkBooks[1].WorkSheets[1].Name := 'sheet1';
Sheet := XLApp.Workbooks[1].WorkSheets['sheet1'];
Target.Row := 0;
for iCount := 0 to Target.RowCount - 1 do
begin
for jCount := 0 to Target.ColCount - 1 do
Sheet.cells[iCount + 1, jCount + 1] := Target.Cells[jCount,iCount];
Target.Row := iCount;
end;
XLApp.ActiveWorkbook.SaveAs(FileName:=FileName);
Screen.Cursor := crDefault;
XLApp.ActiveWorkbook.Close;
end;
上面这个方法刚好是stringgrid导出Excel的方法,我自己用过的。
当然你要是用advstringgrid的话还有更简单的方法,不用语句,靠控件就能实现。
查看全文
相关阅读:
openstack controller ha测试环境搭建记录(七)——配置glance
openstack controller ha测试环境搭建记录(六)——配置keystone
openstack controller ha测试环境搭建记录(五)——配置rabbitmq集群
spring classpath & classpath*
SVN相关
eclipse安装springboot插件
Hbase Shell常用命令
CentOS下安装Hbase
CentOS安装JDK-tar.gz文件
Linux常用命令
原文地址:https://www.cnblogs.com/maweiwei/p/12201828.html
最新文章
OSD数据读流程1
[转]ceph网络通信 数据结构分析1
[转]ceph网络通信模块_以monitor模块为例
ES6 ruanyifeng, shim polyfill
Node.js(daemon),tweak(debug ES)/nodejs forever,supervisor--express
hyperledger
区块链,Ethereum-Wallet
RFQ 、IFB、RFP 、RFI的区别是什么
centos 7 yum configuration; yum localinstall
nginx ipv4 ipv6 chrome /firefox remote-address/chrome://net-internals/dns
热门文章
mysql unix domain socket and network socket, ssh key
How to disable a plugin when Jenkins is down?
createrepo local http yum
openstack controller ha测试环境搭建记录(十四)——配置cinder(存储节点)
openstack controller ha测试环境搭建记录(十三)——配置cinder(控制节点)
openstack controller ha测试环境搭建记录(十二)——配置neutron(计算节点)
openstack controller ha测试环境搭建记录(十一)——配置neutron(网络节点)
openstack controller ha测试环境搭建记录(十)——配置neutron(控制节点)
openstack controller ha测试环境搭建记录(九)——配置nova(计算节点)
openstack controller ha测试环境搭建记录(八)——配置nova(控制节点)
Copyright © 2011-2022 走看看
var
iCount, jCount: Integer;
XLApp: Variant;
Sheet: Variant;
begin
Screen.Cursor := crHourGlass;
if not VarIsEmpty(XLApp) then
begin
XLApp.DisplayAlerts := False;
XLApp.Quit;
VarClear(XLApp);
end;
//通过ole创建Excel对象
try
XLApp := CreateOleObject('Excel.Application');
except
Screen.Cursor := crDefault;
Exit;
end;
SaveDialog1.DefaultExt := 'xls';
SaveDialog1.FileName := FileName;XLApp.WorkBooks.Add; //你要把数据放在那里啊,先生成个文件在e:1.xls
XLApp.WorkBooks[1].WorkSheets[1].Name := 'sheet1';
Sheet := XLApp.Workbooks[1].WorkSheets['sheet1'];
Target.Row := 0;
for iCount := 0 to Target.RowCount - 1 do
begin
for jCount := 0 to Target.ColCount - 1 do
Sheet.cells[iCount + 1, jCount + 1] := Target.Cells[jCount,iCount];
Target.Row := iCount;
end;
XLApp.ActiveWorkbook.SaveAs(FileName:=FileName);
Screen.Cursor := crDefault;
XLApp.ActiveWorkbook.Close;
end;
当然你要是用advstringgrid的话还有更简单的方法,不用语句,靠控件就能实现。