var
  sheet: olevariant;
  exls: Variant;
  iRow, iCol : integer;
begin
    try
    exls:=createoleobject('Excel.application');
    exls.Workbooks.Add();  //
    exls.Workbooks[1].WorkSheets[1].Name := 'abc';
    sheet:= exls.workbooks[1].worksheets[1];
    for iRow:=0 to SG1.RowCount-1 do begin
      for iCol := 0 to SG1.ColCount-1 do begin
        sheet.Cells.Item[iRow+1,iCol+1] := SG1.Cells[iCol,iRow];
      end;
    end;
    exls.visible:=true;
当SG1.Cells[iCol,iRow]='6-10'或n-n,n为数字的时候
在excel中自动变成了6月10日,怎么才能在excel中显示6-10

解决方案 »

  1.   

    这是Excel设置的问题
    这样试一试
    sheet.Cells[iRow+1,iCol+1].Text := SG1.Cells[iCol,iRow];
          
      

  2.   

    ColumnRange.Columns[1].numberformatlocal:='@';
      

  3.   

    老兄这句话应该加到哪儿阿,前缀是什么啊
    sheet.ColumnRange.Columns[4].numberformatlocal:='@';我这么些的包错了说没有这个方法
    那里可以查到帮助阿
      

  4.   

    sheet.Columns[4].numberformatlocal:='@'
    我是用SERVER连接的