Home > Software engineering >  Open Excel File in write mode using Button WPF
Open Excel File in write mode using Button WPF

Time:08-15

Hello as the title says I'm trying to make a button that opens a excel file in write mode in wpf but i can't make it work its always opening the excel file in read only.

        private void btnFileOK_Click(object sender, EventArgs e)
    {
        fileExcel = "C:\\Random\\1.xlsx";
        Excel.Application xlApp;
        Excel.Workbook xlWorkbook;
        xlApp = new Excel.Application();
        //open workbook
        xlWorkbook = xlApp.Workbooks.Open(fileExcel, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
        xlApp.Visible = true; 
    }

CodePudding user response:

Call theOpen method with third parameter (ReadOnly) = false.

See MSDN documentation:

ReadOnly

Optional Object. True to open the workbook in read-only mode.

False to open the workbook in r&w mode

  • Related