c# - 如何从 "Full Screen"中的 C#/WPF 打开 Excel 文件?

标签 c# excel

目前我正在使用 C#/WPF 应用程序打开文件

System.Diagnostics.Process.Start("C:\ .... ");

应用程序窗口是否全屏等取决于应用程序的前一个实例在关闭时所处的状态(例如,如果它在全屏时关闭,它会打开一个新实例全屏)

我想做的是在 Excel 中打开一个文件并使其全屏显示。我查看了 Excel 的命令行开关,似乎相当有限,因为我无法通过将 Application.DisplayFullScreen = True 添加到 VBA 模块来修改 excel 文件。

编辑:不清楚,但我打算以全屏模式(没有功能区等)打开它,而不是最大化。

Edit2:按键顺序为 alt+v,u。寻找一种使用 SendKeys 将键序列发送到 excel 窗口的方法

最佳答案

看起来您可以使用 SendKeys。

http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

编辑:这段代码对我有用

一定要 #include System.Windows.Forms 和其他所有需要的东西。

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

public void Go()
{
    Process excel = new Process();
    excel.StartInfo.FileName = @"C:\Test.xlsx";
    excel.Start();

    // Need to wait for excel to start
    excel.WaitForInputIdle();

    IntPtr p = excel.MainWindowHandle;
    ShowWindow(p, 1);
    SendKeys.SendWait("%(vu)");
}

查看此 SO 帖子:

How to open a PDF file by using Foxit/Adobe in full screen mode?

关于c# - 如何从 "Full Screen"中的 C#/WPF 打开 Excel 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20337539/

相关文章:

c# - 可选的设计模式,优势

C# 如何使存储文件的上限为 100 项?

vba - Excel VBA 计时器性能因哪个工作表处于事件状态而异?

excel - 如何将制表符值复制到vba中的单元格

vba - Excel:自动格式化时间的宏(没有日期)

php - Scope - 如何从 laravel excel import 返回错误?

vba - 什么是运行时错误 91?为什么它会出现在我的 Excel VBA 脚本中?

c# - WPF 动画 : How do i make it slide in?

c# - 将文件添加到现有Zip中-性能问题

c# - Quickhull 点未按正确顺序返回