Master4eG, вот такой ис делал для хлс
Add(SimpleForm,2953706,42,133) { Width=295 Height=307 Caption="Demo write xls file" BorderStyle=3 } Add(InlineCode,16411900,294,140) { WorkPoints=#28:doCreateXLS=Создаёт файл XLS|49:doCloseXLS=Закрывает файл после добавления данных|76:doAddData=Добавляет данные в таблицу согластно типа данных (данные в потоке)| EventPoints=#5:onErr| DataPoints=#22:FileName=Имя файла XLS|16:Row=Номер строки|17:Col=Номер колонки| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|3: |0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|3: |21: FStream: PStream;|17: fname:string;|23: FileName:THI_Event;|18: Col:THI_Event;|18: Row:THI_Event;|20: onErr:THI_Event;|3: |72: procedure XlsBeginStream(var XlsStream: PStream; BuildNumber: Word);|47: procedure XlsEndStream(XlsStream: PStream);|53: procedure XlsWriteInteger(var XlsStream: PStream;|51: ACol, ARow: Word;|51: AValue: Integer);|50: procedure XlsWriteReal(var XlsStream: PStream;|48: ACol, ARow: Word;|47: AValue: Double);|0:|52: procedure XlsWriteString(var XlsStream: PStream;|50: ACol, ARow: Word;|52: AValue: string); |3: |50: procedure doCreateXLS(var dt:TData; idx:word);|49: procedure doCloseXLS(var dt:TData; idx:word);|48: procedure doAdddata(var dt:TData; idx:word);|0:|5: end;|0:|14:implementation|0:|3:var|58: CXlsBof: array[0..5] of Word = ($809, 8, 00, $10, 0, 0);|43: CXlsEof: array[0..1] of Word = ($0A, 00);|57: CXlsLabel: array[0..5] of Word = ($204, 0, 0, 0, 0, 0);|56: CXlsNumber: array[0..4] of Word = ($203, 14, 0, 0, 0);|52: CXlsRk: array[0..4] of Word = ($27E, 10, 0, 0, 0);|6: |37:procedure THiAsmClass.XlsBeginStream;|5:begin|28: CXlsBof[4] := BuildNumber;|44: XlsStream.Write(CXlsBof, SizeOf(CXlsBof));|4:end;|0:|35:procedure THiAsmClass.XlsEndStream;|5:begin|44: XlsStream.Write(CXlsEof, SizeOf(CXlsEof));|4:end;|0:|38:procedure THiAsmClass.XlsWriteInteger;|15:var V: Integer;|5:begin|20: CXlsRk[2] := ARow;|20: CXlsRk[3] := ACol;|42: XlsStream.Write(CXlsRk, SizeOf(CXlsRk));|27: V := (AValue shl 2) or 2;|24: XlsStream.Write(V, 4);|4:end;|0:|35:procedure THiAsmClass.XlsWriteReal;|5:begin|24: CXlsNumber[2] := ARow;|24: CXlsNumber[3] := ACol;|50: XlsStream.Write(CXlsNumber, SizeOf(CXlsNumber));|42: XlsStream.Write(AValue, SizeOf(Double));|4:end;|0:|37:procedure THiAsmClass.XlsWriteString;|12:var L: Word;|5:begin|22: L := Length(AValue);|24: CXlsLabel[1] := 8 + L;|23: CXlsLabel[2] := ARow;|23: CXlsLabel[3] := ACol;|20: CXlsLabel[5] := L;|48: XlsStream.Write(CXlsLabel, SizeOf(CXlsLabel));|39: XlsStream.Write(Pointer(AValue)^, L);|4:end;|0:|34:procedure THiAsmClass.doCreateXLS;|5:begin|50: fname := ReadString(dt,FileName, 'C:\Demo.xls');|39: FStream := NewWriteFileStream(fname);|29: XlsBeginStream(FStream, 0);|4:end;|0:|33:procedure THiAsmClass.doCloseXLS;|5:begin|24: XlsEndStream(FStream);|15: FStream.Free;|4:end;|0:|32:procedure THiAsmClass.doAdddata;|16:var stmp:string;|17: itmp:integer;|14: rtmp:real;|16: r,c:integer;|16: tmpdt:TData;|5:begin|34: r := ReadInteger(tmpdt, Row, 0);|34: c := ReadInteger(tmpdt, Col, 0);|22: case dt.Data_type of|20: data_str: begin|38: stmp := ToString(dt);|50: XlsWriteString(FStream,c,r,stmp);|19: end;|20: data_int: begin|39: itmp := ToInteger(dt);|51: XlsWriteInteger(FStream,c,r,itmp);|19: end;|20: data_real: begin|36: rtmp := ToReal(dt);|48: XlsWriteReal(FStream,c,r,rtmp);|19: end;|57: else _hi_onEvent(onErr, 'Error type add'); |6: end;|4:end;|0:|4:end.| link(onErr,620829:doAdd,[]) link(FileName,4143061:Var3,[(300,124)]) link(Row,15655604:Position,[]) link(Col,9191990:Text,[(314,124)(447,124)]) } Add(Button,12608348,119,154) { Left=5 Top=105 Width=75 Caption="string add" Data=String(demo Демонстрация кирилицы) link(onClick,343469:doWork2,[]) } Add(Button,12273742,119,196) { Left=5 Top=135 Width=75 Caption="inteher add" Data=Integer(10) link(onClick,5502245:doWork2,[]) } Add(Button,16456213,119,245) { Left=5 Top=165 Width=75 Caption="real add" Data=Real(129.54) link(onClick,10471912:doWork2,[]) } Add(HubEx,343469,196,154) { link(onEvent,16411900:doAddData,[]) } Add(HubEx,5502245,175,196) { link(onEvent,343469:doWork3,[(200,202)]) } Add(Button,4115749,119,70) { Left=10 Top=10 Width=70 Caption="Open" link(onClick,16411900:doCreateXLS,[(218,76)(218,146)]) } Add(Edit,8673961,245,77) { Left=95 Top=10 Width=180 Text="Demo1.xls" } Add(Button,5982830,119,112) { Left=10 Top=45 Width=70 Caption="Close" link(onClick,16411900:doCloseXLS,[(199,118)(199,153)]) } Add(Edit,6334028,343,77) { Left=95 Top=45 Width=30 Text="0" DataType=2 ReadOnly=0 } Add(UpDown,15655604,301,77) { Left=125 Top=45 link(onPosition,6334028:doText,[]) } Add(Label,15046177,42,84) { Left=150 Top=50 Width=26 Height=17 Caption="Row" } Add(Edit,9191990,441,77) { Left=190 Top=45 Width=30 Text="0" DataType=2 } Add(UpDown,12404070,399,77) { Left=220 Top=45 link(onPosition,9191990:doText,[]) } Add(Label,8234793,35,77) { Left=245 Top=50 Width=19 Height=17 Caption="Col" } Add(Memo,620829,364,140) { Left=105 Top=105 Width=165 Height=110 ScrollBars=2 } Add(Button,831636,119,301) { Left=5 Top=195 Width=75 Caption="Err data" link(onClick,10471912:doWork3,[(165,307)]) } Add(HubEx,10471912,161,245) { link(onEvent,5502245:doWork3,[(179,251)]) } Add(InfoTip,9458219,287,196) { Info=#12:1) Open file|40:2) Add string, real, intger for buttons.|14:3) Close file.| Font=[MS Sans Serif,12,1,255,1] Frame=1 HAlign=0 Width=351 Height=60 } Add(Button,3544816,105,441) { Left=10 Top=235 Width=260 Height=25 Caption="Auto creator data file 10x1000" link(onClick,6665458:doEvent1,[]) } Add(InlineCode,14243757,259,441) { WorkPoints=#28:doCreateXLS=Создаёт файл XLS|49:doCloseXLS=Закрывает файл после добавления данных|76:doAddData=Добавляет данные в таблицу согластно типа данных (данные в потоке)| EventPoints=#5:onErr| DataPoints=#22:FileName=Имя файла XLS|16:Row=Номер строки|17:Col=Номер колонки| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|3: |0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|3: |21: FStream: PStream;|17: fname:string;|23: FileName:THI_Event;|18: Col:THI_Event;|18: Row:THI_Event;|20: onErr:THI_Event;|3: |72: procedure XlsBeginStream(var XlsStream: PStream; BuildNumber: Word);|47: procedure XlsEndStream(XlsStream: PStream);|53: procedure XlsWriteInteger(var XlsStream: PStream;|51: ACol, ARow: Word;|51: AValue: Integer);|50: procedure XlsWriteReal(var XlsStream: PStream;|48: ACol, ARow: Word;|47: AValue: Double);|0:|52: procedure XlsWriteString(var XlsStream: PStream;|50: ACol, ARow: Word;|52: AValue: string); |3: |50: procedure doCreateXLS(var dt:TData; idx:word);|49: procedure doCloseXLS(var dt:TData; idx:word);|48: procedure doAdddata(var dt:TData; idx:word);|0:|5: end;|0:|14:implementation|0:|3:var|58: CXlsBof: array[0..5] of Word = ($809, 8, 00, $10, 0, 0);|43: CXlsEof: array[0..1] of Word = ($0A, 00);|57: CXlsLabel: array[0..5] of Word = ($204, 0, 0, 0, 0, 0);|56: CXlsNumber: array[0..4] of Word = ($203, 14, 0, 0, 0);|52: CXlsRk: array[0..4] of Word = ($27E, 10, 0, 0, 0);|6: |37:procedure THiAsmClass.XlsBeginStream;|5:begin|28: CXlsBof[4] := BuildNumber;|44: XlsStream.Write(CXlsBof, SizeOf(CXlsBof));|4:end;|0:|35:procedure THiAsmClass.XlsEndStream;|5:begin|44: XlsStream.Write(CXlsEof, SizeOf(CXlsEof));|4:end;|0:|38:procedure THiAsmClass.XlsWriteInteger;|15:var V: Integer;|5:begin|20: CXlsRk[2] := ARow;|20: CXlsRk[3] := ACol;|42: XlsStream.Write(CXlsRk, SizeOf(CXlsRk));|27: V := (AValue shl 2) or 2;|24: XlsStream.Write(V, 4);|4:end;|0:|35:procedure THiAsmClass.XlsWriteReal;|5:begin|24: CXlsNumber[2] := ARow;|24: CXlsNumber[3] := ACol;|50: XlsStream.Write(CXlsNumber, SizeOf(CXlsNumber));|42: XlsStream.Write(AValue, SizeOf(Double));|4:end;|0:|37:procedure THiAsmClass.XlsWriteString;|12:var L: Word;|5:begin|22: L := Length(AValue);|24: CXlsLabel[1] := 8 + L;|23: CXlsLabel[2] := ARow;|23: CXlsLabel[3] := ACol;|20: CXlsLabel[5] := L;|48: XlsStream.Write(CXlsLabel, SizeOf(CXlsLabel));|39: XlsStream.Write(Pointer(AValue)^, L);|4:end;|0:|34:procedure THiAsmClass.doCreateXLS;|5:begin|50: fname := ReadString(dt,FileName, 'C:\Demo.xls');|39: FStream := NewWriteFileStream(fname);|29: XlsBeginStream(FStream, 0);|4:end;|0:|33:procedure THiAsmClass.doCloseXLS;|5:begin|24: XlsEndStream(FStream);|15: FStream.Free;|4:end;|0:|32:procedure THiAsmClass.doAdddata;|16:var stmp:string;|17: itmp:integer;|14: rtmp:real;|16: r,c:integer;|16: tmpdt:TData;|5:begin|34: r := ReadInteger(tmpdt, Row, 0);|34: c := ReadInteger(tmpdt, Col, 0);|22: case dt.Data_type of|20: data_str: begin|38: stmp := ToString(dt);|50: XlsWriteString(FStream,c,r,stmp);|19: end;|20: data_int: begin|39: itmp := ToInteger(dt);|51: XlsWriteInteger(FStream,c,r,itmp);|19: end;|20: data_real: begin|36: rtmp := ToReal(dt);|48: XlsWriteReal(FStream,c,r,rtmp);|19: end;|57: else _hi_onEvent(onErr, 'Error type add'); |6: end;|4:end;|0:|4:end.| link(FileName,4143061:Var2,[]) link(Row,5593001:Position,[(272,424)(293,424)]) link(Col,6527630:Position,[(279,433)(349,433)]) } Add(GetDataEx,4143061,259,119) { Angle=3 link(Data,8673961:Text,[(251,124)]) } Add(Random,11606368,399,385) { Max=2 link(onRandom,7269683:doEvent,[]) } Add(For,6527630,343,385) { End=9 link(onEvent,11606368:doRandom,[]) } Add(For,5593001,287,385) { End=9999 link(onEvent,6527630:doFor,[]) link(onStop,101109:doEvent1,[(335,398)(335,496)]) } Add(IndexToChanel,7269683,448,385) { Count=3 link(onEvent1,8740091:doData,[]) link(onEvent2,10514503:doData,[(524,398)(524,433)]) link(onEvent3,6411959:doData,[(514,405)(514,475)]) } Add(DoData,8740091,539,385) { Data=Integer(10) link(onEventData,300169:doWork1,[(585,391)]) } Add(DoData,10514503,539,427) { Data=Real(20.05) link(onEventData,300169:doWork2,[]) } Add(DoData,6411959,539,469) { Data=String(Demo Демо) link(onEventData,8240117:doWork2,[]) } Add(InfoTip,14688046,112,553) { Info=#32:Auto create file col=10 row=1000| Font=[MS Sans Serif,12,1,255,1] Frame=1 HAlign=0 Width=260 Height=39 } Add(HubEx,8240117,602,469) { link(onEvent,14243757:doAddData,[(620,475)(620,525)(247,525)(247,461)]) } Add(HubEx,300169,581,427) { link(onEvent,8240117:doWork1,[(606,433)]) } Add(Hub,101109,350,490) { link(onEvent1,14243757:doCloseXLS,[(376,496)(376,481)(235,481)(235,454)]) link(onEvent2,12326381:doMessage,[(416,503)(416,475)]) } Add(Hub,6665458,168,441) { link(onEvent1,14243757:doCreateXLS,[]) link(onEvent2,5593001:doFor,[(209,454)(209,391)]) } Add(Message,12326381,448,469) { Message="End create file" }
|