Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Windows任务计划程序打开Excel文件_Java_Background Process_Talend_Windows Task Scheduler - Fatal编程技术网

Java 使用Windows任务计划程序打开Excel文件

Java 使用Windows任务计划程序打开Excel文件,java,background-process,talend,windows-task-scheduler,Java,Background Process,Talend,Windows Task Scheduler,我有一份Talend工作,在满足某些条件时将打开Excel文件。Excel文件中有很多VBA,可以从SQL Server读取并创建文档。从Open Studio运行时,我可以成功运行Talend作业。我现在尝试在Windows任务计划程序中计划作业,该任务计划程序将每隔5分钟运行Talend作业以打开Excel文件 我尝试使用tJava组件使用Desktop类打开文件,但没有成功 Desktop dt = Desktop.getDesktop(); dt.open(new File("C:/Us

我有一份Talend工作,在满足某些条件时将打开Excel文件。Excel文件中有很多VBA,可以从SQL Server读取并创建文档。从Open Studio运行时,我可以成功运行Talend作业。我现在尝试在Windows任务计划程序中计划作业,该任务计划程序将每隔5分钟运行Talend作业以打开Excel文件

我尝试使用tJava组件使用Desktop类打开文件,但没有成功

Desktop dt = Desktop.getDesktop();
dt.open(new File("C:/Users/<username>/<filepath info>/TEST.xlsm"));
Desktop dt=Desktop.getDesktop();
dt.open(新文件(“C:/Users///TEST.xlsm”);
现在,我尝试使用带有以下命令的TSSystem组件:

"cmd.exe /c start excel \"C:/Users/<username>/<filepath info>/TEST.xlsm\""
cmd.exe/c start excel\'c:/Users///TEST.xlsm\'

我认为它不起作用,因为当计划时,它会变成一个后台进程,没有对桌面或cmd的引用,它可以在上面运行命令。如何使用Java从后台作业打开Excel文件?

如果使用start命令且要启动的文件路径包含空格,则必须为start命令指定标题

import java.io.IOException;

    class StartExcel {
        public static void main(String args[])
            throws IOException
        {
            String fileName = "c:\\temp\\xls\\test2.xls";
            String[] commands = {"cmd", "/c", "start", "\"DummyTitle\"",fileName};
            Runtime.getRuntime().exec(commands);
        }
    }

它的功能。

如果使用start命令且要启动的文件路径包含空格,则必须为start命令指定标题

import java.io.IOException;

    class StartExcel {
        public static void main(String args[])
            throws IOException
        {
            String fileName = "c:\\temp\\xls\\test2.xls";
            String[] commands = {"cmd", "/c", "start", "\"DummyTitle\"",fileName};
            Runtime.getRuntime().exec(commands);
        }
    }

它的功能。

可能包含空格吗?@RealHowTo是的,它包含空格,但是用引号括起来应该可以让我绕过它,对吗?可能包含空格吗?@RealHowTo是的,它包含空格,但是用引号括起来应该可以让我绕过它,对吗?