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

sid
- 43
- 1
- 1
- 6
-
2I don't see a question being asked here, or even a description of a problem. I just see some code that isn't even properly formatted. Can you [edit] to actually explain what the problem is with the code you posted, and then ask a question about what you want us to help you with? Thanks. – Ken White Jun 28 '13 at 13:08
1 Answers
6
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.

rodrigo
- 94,151
- 12
- 143
- 190
-
-
In modern .NET (Core and NET5+) UseShellExecute defaults to false, this code would work: `Process.Start(new ProcessStartInfo(outputFilePath) { UseShellExecute = true });` – Markus Knappen Johansson Jul 15 '23 at 09:15