【文章】如何用Delphi控制Excel儲存格合併? 【編輯】領航天使
【作者】a6475
【內文】來源:http://delphi.ktop.com.tw/topic.asp?topic_id=45774
Q:
我用下列方法動態create excel ole物件
msexcel:= CreateOleObject('Excel.Application');
1.我要把 A1..Z1 CELL合併, 該下何指令?
.我如何知道 cell[2,3]= B3, cell[1,1]=A1
2.以往我們都是指定 cell[2,3]內的值, 但如果想知道是那一個格址呢?
(除了用計算公式去算出來外, 有沒有指令馬上知道)
A:
1.MyExcel.Range['C1','D8'].Select;
MyExcel.Selection.Merge; //合拼儲存格
2.cell[1,3].address
or
cell[1,3].address(xlA1)
3.以下是C++ Builder將Excel的Cell Merge方法您參考看看:
//合併CELL
/*
Cells=Worksheet.OlePropertyGet("Cells");
Variant Cell1=Cells.OlePropertyGet("Cells",x1,y1);
Variant Cell2=Cells.OlePropertyGet("Cells",x2,y2);
Range=Worksheet.OlePropertyGet("Range",Cell1,Cell2);
Range.OleFunction("Merge");
4.參考這一篇:
http://delphi.ktop.com.tw/topic.asp?topic_id=28371
【文章】如何更改ShowMessage的字體? 【編輯】領航天使
【作者】liorex
【內文】來源:http://delphi.ktop.com.tw/topic.asp?topic_id=29646
var
from : TForm ;
lab : TLabel ;
begin
from := CreateMessageDialog('afsdfadsfasd',mtInformation, [mbOK]);
with from do
begin
lab := TLabel(FindComponent('Message')) ;
if lab <> nil then
begin
lab.Font.Color := clRed ; //你要的顏色在這裡設
lab.Font.Size := 12 ; //字體
lab.Font.Name := '標楷體';//字型
end ;
from.ShowModal;
end;
from.Destroy ;
FreeAndNil(from);
end;
【文章】如何將逗點連接的字串拆開? 【編輯】領航天使
【作者】qoo1234 / P.D.
【內文】來源:http://delphi.ktop.com.tw/topic.asp?topic_id=45586
Q:
請問如何把字串拆開 ?
s:='abc,bbb,ccc,aaa,add,ddc';
以上字串如何把它分開為 :
abc
bbb
ccc
aaa
add
ddc
A1:
procedure TForm1.Button1Click(Sender: TObject);
var Str:String;
SL:TStringList;
begin
Str:='abc,bbb,ccc,aaa,add,ddc';
SL:=TStringList.Create;
SL.CommaText:=Str;
ShowMessage(SL.Text);
SL.Free;
end;
A2:
function TSysUT.getaryStr(var AryList: Array of string; mString: string): boolean;
var xpos: string;
xFind: integer;
i: integer;
begin
xpos:= '';
xfind:= -1;
result:= True;
i:= 0;
while xfind <> 0 do
try
xfind:= pos(',',mString);
if xfind = 0 then break;
xpos:= copy(mString,1,xfind-1);
AryList[i]:= xpos;
Delete(mString,1,length(xpos)+1);
inc(i);
except
on E: Exception do begin
result:= False;
Break;
end;
end;
end;
用法
myAry:= array[0..3] of string;
myStr:= 'AAA,BBB,CCC,DDD'
getaryStr(myAry,myStr);
你就可以發現自動將四組字串分給四個陣列
其他你就再發揮創意來運用吧!