Link to home
Start Free TrialLog in
Avatar of Kristao
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(ExcelObject: 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].WorkSheets[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
ASKER CERTIFIED SOLUTION
Avatar of atul_parmar
atul_parmar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial