峻
峻祁连
Unregistered / Unconfirmed
GUEST, unregistred user!
我用delphi7带的 server页里的Excel组件作数据导出,
代码如下:
procedure TfrmExportExcel.ExportRouteCustomer(path : string;routeRegionName :string);
var
filename,cupono,cuitemno,stshpdt,ndshpdt,balqty,rmk,shtname:string;
sheettype,routedocument,itemindex,sheetnulevariant;
i,j:integer;
newworksheet: _WorkSheet;
begin
try
excelapplication1.Connect;
except
Application.MessageBox('您的计算机上没有安装excel', '错误', MB_OK +
MB_ICONSTOP);
abort;
end;
excelapplication1.Visible[0] :=true;
excelapplication1.Caption :=routeRegionName+'线路客户';
filename:=path +'/'+routeRegionName +'线路客户.xls';
excelapplication1.Workbooks.Add(EmptyParam,0);
//这里是一次创建几个sheet并填充数据的
for j := 0 to WeekDays.Count -1 do
begin
shtname:=WeekDays[j];//星期几;
with excelapplication1.ActiveWorkbook do
begin
itemindex:=sheets[excelapplication1.ActiveWorkbook.Worksheets.Count];
SheetNu:=1;
newworksheet:=excelapplication1.ActiveWorkbook.WorkSheets.Add(EmptyParam,itemindex,SheetNu,EmptyParam,1) as _WorkSheet;
newworksheet.Set_Name(shtname);
ExcelWorkSheet1.ConnectTo(newworksheet);
ExportCustomerOfRoute(newworksheet,routeRegionName,shtname);
end;
end;
//===========这里想按照指定的filename保存,但总是弹出来提示,让用户选择保存路径
而不是自己保存,怎么弄才行呢?
excelapplication1.ActiveWorkbook.SaveCopyAs(filename,0);
//excelapplication1.ActiveWorkbook.Save(0);
// if not excelapplication1.ActiveWorkbook.Saved[0] then
// begin
// excelapplication1.ActiveWorkbook.SaveCopyAs(filename,0);
// excelapplication1.ActiveWorkbook.SaveAs(filename,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
// excelapplication1.SaveWorkspace(filename);
// excelapplication1.Save(filename);
// end;
excelapplication1.Disconnect;
excelapplication1.Quit;
end;
------------------
这个怎么连个帮助都没有,还是我装的不全?郁闷啊?
大侠们赶紧帮我改一改,很急啊
代码如下:
procedure TfrmExportExcel.ExportRouteCustomer(path : string;routeRegionName :string);
var
filename,cupono,cuitemno,stshpdt,ndshpdt,balqty,rmk,shtname:string;
sheettype,routedocument,itemindex,sheetnulevariant;
i,j:integer;
newworksheet: _WorkSheet;
begin
try
excelapplication1.Connect;
except
Application.MessageBox('您的计算机上没有安装excel', '错误', MB_OK +
MB_ICONSTOP);
abort;
end;
excelapplication1.Visible[0] :=true;
excelapplication1.Caption :=routeRegionName+'线路客户';
filename:=path +'/'+routeRegionName +'线路客户.xls';
excelapplication1.Workbooks.Add(EmptyParam,0);
//这里是一次创建几个sheet并填充数据的
for j := 0 to WeekDays.Count -1 do
begin
shtname:=WeekDays[j];//星期几;
with excelapplication1.ActiveWorkbook do
begin
itemindex:=sheets[excelapplication1.ActiveWorkbook.Worksheets.Count];
SheetNu:=1;
newworksheet:=excelapplication1.ActiveWorkbook.WorkSheets.Add(EmptyParam,itemindex,SheetNu,EmptyParam,1) as _WorkSheet;
newworksheet.Set_Name(shtname);
ExcelWorkSheet1.ConnectTo(newworksheet);
ExportCustomerOfRoute(newworksheet,routeRegionName,shtname);
end;
end;
//===========这里想按照指定的filename保存,但总是弹出来提示,让用户选择保存路径
而不是自己保存,怎么弄才行呢?
excelapplication1.ActiveWorkbook.SaveCopyAs(filename,0);
//excelapplication1.ActiveWorkbook.Save(0);
// if not excelapplication1.ActiveWorkbook.Saved[0] then
// begin
// excelapplication1.ActiveWorkbook.SaveCopyAs(filename,0);
// excelapplication1.ActiveWorkbook.SaveAs(filename,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
// excelapplication1.SaveWorkspace(filename);
// excelapplication1.Save(filename);
// end;
excelapplication1.Disconnect;
excelapplication1.Quit;
end;
------------------
这个怎么连个帮助都没有,还是我装的不全?郁闷啊?
大侠们赶紧帮我改一改,很急啊