参考下例:
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=True;
ExcelApplication1.Workbooks.Add(NULL,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets[1] as _WorkSheet);
for idx:=1 to 30do
begin
ExcelWorksheet1.Cells.Item[idx,1]:='Hello '+IntToStr(idx);
ExcelWorksheet1.Cells.Item[idx,2]:= idx;
end;
ExcelWorksheet1.Cells.Item[31,2]:='=SUM(B1:B30)';
ShowMessage('Total is '+ExcelWorksheet1.Cells.Item[31,2]);
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
将其中字段转成数据库就可