Opening an excel file from button click on a windo

2019-07-23 01:25发布

private void btnOpenReport_Click(object sender, EventArgs e)
{  
    if (System.IO.File.Exists(outputFilePath))
    {
        Process.Start(new ProcessStartInfo("excel.exe", " /select, " + outputFilePath.Replace("\\\\", "\\")));
     }
}

1条回答
相关推荐>>
2楼-- · 2019-07-23 01:44

Probably you should just start the Excel file directly with property UseShellExecute to true, which is the default, and it will launch the default associated program, most likely Excel itself:

Process.Start(outputFilePath);

Another matter is why you are doing that Replace, but that's probably off-topic here.

查看更多
登录 后发表回答