VFP9导出文件名_打开导出文件夹_选中导出文件
SET TALK OFF
SET SAFETY OFF&& 覆盖不问
IF checkKeHu AND checkJieZhang AND checkXianShangXia
ELSE
MESSAGEBOX('选择 客户单位 结账方式 线上线下 才能合并导出...','提示')
RETURN
ENDIF
SELECT grid1XaoTiaoJian&& 必须
COUNT ALL FOR 选择='√' TO xuanShuAll
IF xuanShuAll = 0&& RECCOUNT()=0
MESSAGEBOX('勾选要导出的记录...','提示')
RETURN
ENDIF
SELECT ;
TRIM(货名) as 货名,TRIM(型号) 型号,规格,;
COUNT(*) 笔数,SUM(销售数) as 总销售数,;
SUM(销售单价*销售数)/SUM(销售数) as 销售平均单价,;
SUM(进货单价均*销售数)/SUM(销售数) as 进货平均单价,;
SUM(进货单价均*销售数) as 总成本价,;
SUM(应收) as 总应收,sum(实收) as 总实收 ;
FROM db/xao ;
WHERE 选择='√' ;
ORDER BY 货名,型号,规格 ;
GROUP BY 货名,型号,规格 ;
INTO CURSOR tmpXaoHeBingExport
keHuDanWei = UPPER(ALLTRIM(thisform.txt客户单位.Value))
xlsFileName = keHuDanWei + TTOC(DATETIME(),1) + '_销售明细_合并'
COPY TO Excel\&xlsFileName. FIELDS EXCEPT 进货平均单价,总成本价 TYPE XL5&& FOR 选择='√' FIELDS EXCEPT 选择,来源,本次代码
SELECT grid1XaoTiaoJian&& 从新的临时表中转到原始的表
MESSAGEBOX('导出XLS成功...','提示')
&&打开导出文件夹
*!* ox = CREATEOBJECT("wscript.shell")
*!* ox.run(".\Excel",1,.f.)
&& 于2020后查VBS/VB方面的打开文件夹并选中文件方面的代码而改写
obj = CreateObject("wscript.shell")&&创建对象
obj.run("%systemroot%\explorer.exe /select, .\Excel\"+xlsFileName+".xls")&&打开文件夹并选中指定的文件