try
       ExcelApplication1.Connect;
       ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0));
       ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets.Add(EmptyParam,EmptyParam,EmptyParam,EmptyParam,0) as _worksheet);
   except
       webapplication.ShowMessage('服务器端excel启动失败!');
   end;
   //------------------------------------   // ds:=datamodule1.ds;
    with ExcelWorksheet1.Cells do
     begin
         cells.Item[1,1]:='资料管理中心报表(查询结果)';
         cells.Item[2,1]:=datetoStr(now);
         for i:=0 to ds.FieldCount -1 do
             cells.Item[3,i+1]:=ds.fields[i].DisplayLabel;
         r:=4;
         ds.First;
         repeat
            for i:=0 to ds.FieldCount -1 do
                Cells.Item[r,i+1]:=ds.fields[i].Value;
            r:=r+1;
            ds.Next;
         until ds.Eof;
    end;    s:=TIWServerController.NewCacheFile('ggg');
    s:=change_postfix(s,'xls');
   // ExcelApplication1.Visible[0]:=True;
   // ExcelWorkSheet1.PrintPreview;
    if FileExists(s) then
     DeleteFile(s);    ExcelWorkSheet1.SaveAs(s);    ExcelApplication1.Quit;
    ExcelWorkSheet1.Disconnect;
    ExcelWorkbook1.Disconnect;
    ExcelApplication1.Disconnect;
    abort;    s:=WebApplication.URLBase + '/cache/' + ExtractFilename(s);
    if IWCheckBox1.Checked then
    begin
        //s:='NewWindow("'+s+'", "","resizable=yes,toolbar=yes,scrollbars=yes");';
        s:='NewWindow("'+s+'", "","");';
        self.AddToInitProc(s);
    end ;{else begin
        with TformMainReport.Create(webapplication) do
        begin
             IWframe1.src:=s;
             show;
        end;
        free;
    end; }错误发生在红色地方,保存出错,知道的请帮忙