Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I'm using below code to bind excel file in panel control but it first open individually then hide and load into panel control. I directly want to open this file in panel how can I do this.
C#
string xlsFileName = @"C:\Exceptions.xlsx";    
    private Excel.Workbook m_workbook;
    const int WM_SYSCOMMAND = 274;
    const int SC_MAXIMIZE = 61488;
    Process proc;

    [DllImport("user32.dll")]
    static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

    [DllImport("user32.dll")]
    static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

    [DllImport("ole32.dll")]
    static extern int GetRunningObjectTable(uint reserved, out IRunningObjectTable pprot);

    [DllImport("ole32.dll")]
    static extern int CreateBindCtx(uint reserved, out IBindCtx pctx);

private void Form4_Load(object sender, EventArgs e)
    {
      //Run Notepad application inside Panel1 control
      proc = Process.Start(xlsFileName);
      proc.WaitForInputIdle();
      SetParent(proc.MainWindowHandle, this.panel1.Handle);
      SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
    }


thanks
Posted

1 solution

You are going to need an element of Excel Automation.

try this below.

http://stackoverflow.com/questions/8906670/how-to-open-excel-file-with-read-only-protection[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900