RichEdit讀取Xls文件,保留表格樣式

 

CxGrid 導出 Excel
uses cxGridExportLink;
ExportGridToExcel(
'c: emp.xls',self.cxgrd1);

RichEdit讀取Xls文件,保留表格樣式
uses Clipbrd,ComObj;

procedure TForm3.btn1Click(Sender: TObject);
var 
  xls:variant; 
begin
  uredt1.Clear;
  Clipboard.Clear;
  xls:
=createoleobject( 'Excel.Application');
  
try
    xls.displayalerts :
= false;       //取掉提示框
    xls.workbooks.open(  'c: emp.xls ',false);
    
try
      xls.worksheets[
1].range[ 'a:e '].copy;//你要選擇的列
      uredt1.pastefromclipboard;
    
finally
      xls.WorkBooks.Close;
      xls.quit;
    end;
    Clipboard.Clear;
  except
    showmessage(
'沒安裝 Excel!');
  end;
end; 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章