eu to usando este codigo para criar arquivos do excel atraves do delphi, só que eu queria saber se alguem sabe como eu posso fazer para ver se um valor que eu to colocando no delphi e numerico, porque se for numerico eu queria saber se alguem sabe como eu faço para mudar a propriedade da celula do excel de tipo geral para tipo numero.
esse é uma maneira procedure TForm2.ExportDBGrid(toExcel: Boolean); var bm: TBookmark; col, row: Integer; sline: String; mem: TMemo; ExcelApp: Variant; begin Screen.Cursor := crHourglass; ADOQuery2.Close; ADOQuery2.Open; DBGrid1.DataSource.DataSet.DisableControls; bm := DBGrid1.DataSource.DataSet.GetBookmark; DataSource2.DataSet.First; // create the Excel object if toExcel then begin ExcelApp := CreateOleObject('Excel.Application'); ExcelApp.WorkBooks.Add(xlWBatWorkSheet); ExcelApp.WorkBooks[1].WorkSheets[1].Name := 'Teste'; end; // First we send the data to a memo // works faster than doing it directly to Excel mem := TMemo.Create(nil); mem.Visible := false; mem.Parent := Form2; mem.Clear; sline := ''; Gauge1.MaxValue := DataSource2.DataSet.RecordCount; Gauge1.Progress := 1; // add the info for the column names for col := 0 to DBGrid.FieldCount - 1 do begin sline := sline + DBGrid.Fields[col].DisplayLabel + #9; Gauge1.Progress := Gauge1.Progress + 1; end; mem.Lines.Add(sline); // get the data into the memo DataSource2.DataSet.First; for row := 0 to DataSource2.DataSet.RecordCount-1 do begin sline := ''; for col := 0 to DataSource2.DataSet.FieldCount-1 do begin sline := sline + DataSource2.DataSet.Fields[col].AsString + #9; //ShowMessage(DataSource2.DataSet.Fields[row].AsString); end; Gauge1.Progress := Gauge1.Progress + 1; mem.Lines.Add(sline); DataSource2.DataSet.Next; end; Gauge1.Progress := Gauge1.MaxValue; // we copy the data to the clipboard mem.SelectAll; mem.CopyToClipboard; // if needed, send it to Excel // if not, we already have it in the clipboard if toExcel then begin ExcelApp.Workbooks[1].WorkSheets['Teste'].Paste; ExcelApp.Visible := true; end; FreeAndNil(mem); //FreeAndNil(ExcelApp); DataSource2.DataSet.GotoBookmark(bm); DataSource2.DataSet.FreeBookmark(bm); DataSource2.DataSet.EnableControls; Screen.Cursor := crDefault; end; ----------------------------------- e essa é outra ExcelApplicationl := TExcelApplication.Create(nil); ExcelApplicationl.Workbooks.Add(EmptyParam, 0); ExcelApplicationl.Visible[0] := True; Planilha := ExcelApplicationl.WorkBooks[1].WorkSheets[1]; ADOQuery2.Open; for C := l to ADOQuery2.FieldCount do begin Planilha.Cells[l,C].Select; Planilha.Cells[l,C].Font.Bold := True; Planilha.Cells[l,C].Value := ADOQuery2.Fields[C-1].DisplayLabel; end; L := 2; while not ADOQuery2.Eof do begin for C := 1 to ADOQuery2.FieldCount do begin //Planilha.Cells[L,C].Select; Planilha.Cells[L,C].Value := ADOQuery2.Fields [C-1].AsString; end; L := L + 1; ADOQuery2.Next; end; // ADOQuery2.Close; ExcelApplicationl.Free; -- Leonardo Carlos Baldino - The Highlander [As partes desta mensagem que não continham texto foram removidas]