0

我编写了一个从 excel 生成报告的 foxpro 程序。在最后的过程中,程序生成了两(2)个excel。我创建了一个新工作簿并将两个输出 excel 表复制到新工作簿中。如何关闭这两个excel文件?

我的代码

**creating new workbook
XL = tmp.application
XL.workbooks.ADD()
XL.visible = .T.
XLsheet = XL.ActiveSheet

**opening the aging excel output
sheetdir=SYS(5)+SYS(2003)+"\temp\EXCEL1.xls"
XL.workbooks.OPEN(sheetdir)
XL.worksheets.COPY(XLsheet)
XL.ActiveSheet.UsedRange.EntireColumn.Autofit
XL.ActiveSheet.name="P1"
xl.cells(1,1).value="xx"

XLsheet = XL.ActiveSheet
**opening the unvalidated excel output
sheetdir=SYS(5)+SYS(2003)+"\temp\EXCEL2.xls"
XL.workbooks.OPEN(sheetdir)
XL.worksheets.COPY(XLsheet)
XL.ActiveSheet.UsedRange.EntireColumn.Autofit
XL.ActiveSheet.name="P2"
4

2 回答 2

0

您可以使用 Workbook 的 Close() 方法。

PS:请检查您之前的问题并关闭它们。

于 2016-08-08T08:18:53.930 回答
0

这就是我所做的:

#define xlNormal 39  && defines the version of Excel
oxl = createobject("Excel.Application")
oxl.Workbooks.add()
oBook = oxl.ActiveWorkbook()
oxl.visible = .f.
osheet = oxl.activesheet

 && update the worksheet

 oxl.DisplayAlerts = .f. && do not invoke any dialog 

 oBook.saveas(mfilex,xlNormal )
 && you can use oBook.Close() if you just want to close the book without saving

 oxl.quit()
 release oxl
于 2016-08-16T15:57:46.260 回答