F
funny_0415
Unregistered / Unconfirmed
GUEST, unregistred user!
菜鸟问题,在全文检索中找了好久,都没找到想要答案,请大家帮忙解答
我做了一个EXCEL模板,导出EXCEL时,会调用模板
程序如下:
xlsfilename1:='F:/自制模板/A.xls';
ExcelApplication1 := TExcelApplication.Create(Application);
ExcelWorksheet1 := TExcelWorksheet.Create(Application);
ExcelWorkbook1 := TExcelWorkbook.Create(Application);
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=true;
ExcelApplication1.Workbooks.Add(xlsfilename1, 0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _worksheet);
adoquery2.first;
j:=1;
while not adoquery2.Eof do
begin
j:=j+1;
ExcelWorksheet1.Cells.Item[j,1]:=trim(adoquery2.FieldByName('A').AsString);
ExcelWorksheet1.Cells.Item[j,2]:=trim(adoquery2.FieldByName('B).asstring);
ExcelWorksheet1.Cells.Item[j,3]:=trim(adoquery2.FieldByName('C).asstring);
ExcelWorksheet1.Cells.Item[j,4]:=trim(adoquery2.FieldByName('D').asstring);
ExcelWorksheet1.Cells.Item[j,5]:=trim(adoquery2.FieldByName('E').asstring);
ExcelWorksheet1.Cells.Item[j,6]:=trim(adoquery2.FieldByName('F').asstring);
ExcelWorksheet1.Cells.Item[j,11]:=trim(adoquery2.FieldByName('ww').asstring);
adoquery2.Next;
end;
IF FileExists('C:/A.xls') Then
DeleteFile('C:/A.xls');
excelworksheet1.Saveas('C:/A.xls');
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
excelapp:=createoleobject('Excel.application');
excelapp.visible:=true;
workbook:=excelapp.workbooks.open('C:/A.xls');
问题1:
由于资料量很大,所以导出EXCEL时,会跑很长时间,
在这段时间,如果鼠标点击到EXCEL的资料,就会出错,
请问怎样才能在跑资料时将EXCEL隐藏,跑完后再将EXCEL打开?
问题2:
如果我在导出EXCEL时,另外还有其他的EXCEL文件处于打开状态,
也会报错
我做了一个EXCEL模板,导出EXCEL时,会调用模板
程序如下:
xlsfilename1:='F:/自制模板/A.xls';
ExcelApplication1 := TExcelApplication.Create(Application);
ExcelWorksheet1 := TExcelWorksheet.Create(Application);
ExcelWorkbook1 := TExcelWorkbook.Create(Application);
ExcelApplication1.Connect;
ExcelApplication1.Visible[0]:=true;
ExcelApplication1.Workbooks.Add(xlsfilename1, 0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _worksheet);
adoquery2.first;
j:=1;
while not adoquery2.Eof do
begin
j:=j+1;
ExcelWorksheet1.Cells.Item[j,1]:=trim(adoquery2.FieldByName('A').AsString);
ExcelWorksheet1.Cells.Item[j,2]:=trim(adoquery2.FieldByName('B).asstring);
ExcelWorksheet1.Cells.Item[j,3]:=trim(adoquery2.FieldByName('C).asstring);
ExcelWorksheet1.Cells.Item[j,4]:=trim(adoquery2.FieldByName('D').asstring);
ExcelWorksheet1.Cells.Item[j,5]:=trim(adoquery2.FieldByName('E').asstring);
ExcelWorksheet1.Cells.Item[j,6]:=trim(adoquery2.FieldByName('F').asstring);
ExcelWorksheet1.Cells.Item[j,11]:=trim(adoquery2.FieldByName('ww').asstring);
adoquery2.Next;
end;
IF FileExists('C:/A.xls') Then
DeleteFile('C:/A.xls');
excelworksheet1.Saveas('C:/A.xls');
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
excelapp:=createoleobject('Excel.application');
excelapp.visible:=true;
workbook:=excelapp.workbooks.open('C:/A.xls');
问题1:
由于资料量很大,所以导出EXCEL时,会跑很长时间,
在这段时间,如果鼠标点击到EXCEL的资料,就会出错,
请问怎样才能在跑资料时将EXCEL隐藏,跑完后再将EXCEL打开?
问题2:
如果我在导出EXCEL时,另外还有其他的EXCEL文件处于打开状态,
也会报错