//注意ExcelApplication1.autoconnect属性
    ExcelApplication1.Caption:='工资分析表';
ExcelApplication1.Workbooks.Add(Null,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
//ExcelWorkbook1.Worksheets[1].name :='全厂工资分析表';
ExcelApplication1.Visible[0]:=True;
ExcelWorksheet1.Cells.Item[1,1]:=datetostr(date)+'全厂工资分析表';
ExcelWorksheet1.Cells.Item[2,1]:='编号';
ExcelWorksheet1.Cells.Item[2,2]:='单位';
ExcelWorksheet1.Cells.Item[2,3]:='人数';
ExcelWorksheet1.Cells.Item[2,4]:='生产一次发';
ExcelWorksheet1.Cells.Item[2,5]:='生产另发';
ExcelWorksheet1.Cells.Item[2,6]:='临时工';
ExcelWorksheet1.Cells.Item[2,7]:='生产补贴';
ExcelWorksheet1.Cells.Item[2,8]:='生产浮动';
ExcelWorksheet1.Cells.Item[2,9]:='生产奖金';
ExcelWorksheet1.Cells.Item[2,10]:='生产合计';
ExcelWorksheet1.Cells.Item[2,11]:='附加费';
ExcelWorksheet1.Cells.Item[2,12]:='教育经费';
ExcelWorksheet1.Cells.Item[2,13]:='工会经费';
ExcelWorksheet1.Cells.Item[2,14]:='人数';
ExcelWorksheet1.Cells.Item[2,15]:='管理一次发';
ExcelWorksheet1.Cells.Item[2,16]:='管理另发';
ExcelWorksheet1.Cells.Item[2,17]:='临时工';
ExcelWorksheet1.Cells.Item[2,18]:='补贴';
ExcelWorksheet1.Cells.Item[2,19]:='浮动';
ExcelWorksheet1.Cells.Item[2,20]:='奖金';
ExcelWorksheet1.Cells.Item[2,21]:='管理合计';
ExcelWorksheet1.Cells.Item[2,22]:='附加费';
ExcelWorksheet1.Cells.Item[2,23]:='教育经费';
ExcelWorksheet1.Cells.Item[2,24]:='工会经费';
ExcelWorksheet1.Cells.Item[2,25]:='人数';
ExcelWorksheet1.Cells.Item[2,26]:='工资总计';
ExcelWorksheet1.Cells.Item[2,27]:='附加费';
ExcelWorksheet1.Cells.Item[2,28]:='教育经费';
ExcelWorksheet1.Cells.Item[2,29]:='工会经费';
ExcelWorksheet1.Cells.Item[2,30]:='总计';
for i := 1 to 15 do
begin
    k:=0;
    for j := 1 to 30 do
    begin
        if j=2 then
        begin
            ExcelWorksheet1.Cells.Item[i+2,j]:=data.datebase.Table_fx.fieldbyname('单位').asstring;
            data.datebase.Table_fx.next;
            k:=1;
            ExcelWorksheet1.Cells.Item[i+2,j+k]:=fx[i,j]
        end
        else
            ExcelWorksheet1.Cells.Item[i+2,j+k]:=fx[i,j];
    end;
end;
ExcelWorksheet1.Cells.Item[17,2]:='合计';
ExcelWorksheet1.range['a1','z1'].mergecells:=true;
ExcelWorksheet1.Cells.Item[1,1].font.Size:=18;
ExcelWorksheet1.range['a1','a1'].HorizontalAlignment :=-4108;
ExcelWorksheet1.Columns.EntireColumn.AutoFit;