我重写了TDBGridEhExportAsXLS.WriteTitle函数,到合并单元格的时候不会写了(技术有点洼),思路也有了,请大家帮我完善一下,相信对大家都有用的。谢谢!
procedure TDBGridEhExportAsXLS.WriteTitle(ColumnsList: TColumnsEhList);
var
i, k,m: Integer;
TitleStr:String;
Function GetTitleRow:Integer;//获取表头最大层数
var
i, k,m: Integer;
MaxRow,Row:Integer;
begin
MaxRow:=1;
for i:=0 to ColumnsList.count-1 do
begin
Row:=1;
m:=0;
for j:=0 to Length(ColumnsList[i].Title.caption)-2 do
begin
if (ColumnsList[i].Title.Caption[j]='|') and ((j-m)>0) and
(ColumnsList[i].Title.Caption[j+1]<>'|') then
begin
Inc(Row);
m:=j+1;
end;
end;
if MaxRow<Row then
MaxRow:=Row;
end;
Result:=MaxRow;
end;
begin
if (DBGridEh.UseMultiTitle=false) or (GetTitleRow=1) then
begin
for i := 0 to ColumnsList.Count - 1 do
begin
WriteStringCell(ColumnsList[i].Title.Caption);
end;
end
else
begin
for i:=0 to ColumnsList.Count-1 do
begin
Frow:=0;
TitleStr:='';
m:=0;
for j:=0 to Length(ColumnsList[i].Title.caption)-2 do//写表头
begin
if (ColumnsList[i].Title.Caption[j]='|') and ((j-m)>0) and //写非最后一行表头
(ColumnsList[i].Title.Caption[j+1]<>'|') then
begin
WriteStringCell(TitleStr);
if i=ColumnsList.count-1 then
begin
Fcol:=i;
end
else
begin
Fcol:=Fcol-1;
Inc(Frow);
end;
m:=j+1;
TitleStr:='';
end
else
begin
TitleStr:=TitleStr+ColumnsList[i].Title.Caption[j];
end;
end;
Frow:=GetTitleRow-1;
TitleStr:=TitleStr+ColumnsList[i].Title.Caption[j];
WriteStringCell(TitleStr); //写最后一行表头
end;
begin
//此处为:按行从左到又合并相临的不为空的内容相同的单元格
end;
begin
//此处为:按列从下到上将内容不为空的单元格和它上面内容为空的单元格合并
end;
Fcol:=0;
Frow:=GetTitleRow;
end;
end;
procedure TDBGridEhExportAsXLS.WriteTitle(ColumnsList: TColumnsEhList);
var
i, k,m: Integer;
TitleStr:String;
Function GetTitleRow:Integer;//获取表头最大层数
var
i, k,m: Integer;
MaxRow,Row:Integer;
begin
MaxRow:=1;
for i:=0 to ColumnsList.count-1 do
begin
Row:=1;
m:=0;
for j:=0 to Length(ColumnsList[i].Title.caption)-2 do
begin
if (ColumnsList[i].Title.Caption[j]='|') and ((j-m)>0) and
(ColumnsList[i].Title.Caption[j+1]<>'|') then
begin
Inc(Row);
m:=j+1;
end;
end;
if MaxRow<Row then
MaxRow:=Row;
end;
Result:=MaxRow;
end;
begin
if (DBGridEh.UseMultiTitle=false) or (GetTitleRow=1) then
begin
for i := 0 to ColumnsList.Count - 1 do
begin
WriteStringCell(ColumnsList[i].Title.Caption);
end;
end
else
begin
for i:=0 to ColumnsList.Count-1 do
begin
Frow:=0;
TitleStr:='';
m:=0;
for j:=0 to Length(ColumnsList[i].Title.caption)-2 do//写表头
begin
if (ColumnsList[i].Title.Caption[j]='|') and ((j-m)>0) and //写非最后一行表头
(ColumnsList[i].Title.Caption[j+1]<>'|') then
begin
WriteStringCell(TitleStr);
if i=ColumnsList.count-1 then
begin
Fcol:=i;
end
else
begin
Fcol:=Fcol-1;
Inc(Frow);
end;
m:=j+1;
TitleStr:='';
end
else
begin
TitleStr:=TitleStr+ColumnsList[i].Title.Caption[j];
end;
end;
Frow:=GetTitleRow-1;
TitleStr:=TitleStr+ColumnsList[i].Title.Caption[j];
WriteStringCell(TitleStr); //写最后一行表头
end;
begin
//此处为:按行从左到又合并相临的不为空的内容相同的单元格
end;
begin
//此处为:按列从下到上将内容不为空的单元格和它上面内容为空的单元格合并
end;
Fcol:=0;
Frow:=GetTitleRow;
end;
end;
解决方案 »
- 有没有人用过rzTabControl或者是rzPageControl控件?
- 关于做IE插件的资料或者书那位提供一下嘛
- delphi中使用fastreport制作动态报表的问题,请帮帮忙?
- 对于一个会VC的人,学会delphi大概需要多长时间
- 提问一个关于分辩率的问题
- DRAWGRID在程序运行中设了TOPROW后,可把某行提到最前头,可为什么用鼠标点击它的滚动条后,这行又跑离了第一行的位置了?怎样解决?
- 怎样处理SQL Server 的事务回滚?
- 请考有关IE扩展的问题
- 求助,关于短信群发!短信发不出去!
- ADOTABLE改写数据库的数据(通过EDIT和POST),有没有真正写入数据库?
- 请教问题:我在ActionList里面创建ClientDataSetApply等敏感TOOLBUTTON,为什么不可以用?
- 很简单,TdxPrintStyleManager 属于哪个组件?马上揭贴!
合并,一般是你计算后得到一个 range ,让后 range.select
然后,range.merge 就可合并了
让我看那个是什么意思,给我100000000000000个号也解决不了我的问题啊,别来捣乱!!