Kristao
asked on
OLE excel
HI there i have a litle problem with excel
Ok i use siplest function to add data from app to excel using OLE. All is OK but there is big probelems with strings :(
i have string 00000100 after i inset it in excel its becomes 100 but i wan't 00000100
function i have:
procedure TfMain.ExcelPut(ExcelObjec t: Variant; SheetName: string;
Row, Col: Integer; Data: string; FontName: string = 'Tahoma';
FontSize: Integer = 0; Color: Integer = clBlack; FontStyles: TFontStyles = []);
var
Sheet: variant;
begin
Sheet := ExcelObject.WorkBooks[1].W orkSheets[ SheetName] ;
Sheet.Cells[Row, Col].Value:= Data;
//Sheet.Cells[Row, Col].FormatCells := 'TEXT'; <<<<<< rhis what i want :)
Sheet.Cells[Row, Col].Font.Color := Color;
if FontName <> '' then
Sheet.Cells[Row, Col].Font.Name := FontName;
if FontSize <> 0 then
Sheet.Cells[Row, Col].Font.Size := FontSize;
if FontSize <> 0 then
Sheet.Cells[Row, Col].Font.Size := FontSize;
Sheet.Cells[Row, Col].Font.Bold := fsBold in FontStyles;
Sheet.Cells[Row, Col].Font.Underline := fsUnderline in FontStyles;
Sheet.Cells[Row, Col].Font.Italic := fsItalic in FontStyles;
end;
so i think before i do insert data i neet do say to what kind of data is it its TEXT its simular as i manul do Format->Cells->Text how to do that i don't know all OLE methods to excel.
thanks
Ok i use siplest function to add data from app to excel using OLE. All is OK but there is big probelems with strings :(
i have string 00000100 after i inset it in excel its becomes 100 but i wan't 00000100
function i have:
procedure TfMain.ExcelPut(ExcelObjec
Row, Col: Integer; Data: string; FontName: string = 'Tahoma';
FontSize: Integer = 0; Color: Integer = clBlack; FontStyles: TFontStyles = []);
var
Sheet: variant;
begin
Sheet := ExcelObject.WorkBooks[1].W
Sheet.Cells[Row, Col].Value:= Data;
//Sheet.Cells[Row, Col].FormatCells := 'TEXT'; <<<<<< rhis what i want :)
Sheet.Cells[Row, Col].Font.Color := Color;
if FontName <> '' then
Sheet.Cells[Row, Col].Font.Name := FontName;
if FontSize <> 0 then
Sheet.Cells[Row, Col].Font.Size := FontSize;
if FontSize <> 0 then
Sheet.Cells[Row, Col].Font.Size := FontSize;
Sheet.Cells[Row, Col].Font.Bold := fsBold in FontStyles;
Sheet.Cells[Row, Col].Font.Underline := fsUnderline in FontStyles;
Sheet.Cells[Row, Col].Font.Italic := fsItalic in FontStyles;
end;
so i think before i do insert data i neet do say to what kind of data is it its TEXT its simular as i manul do Format->Cells->Text how to do that i don't know all OLE methods to excel.
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.