I have made a code in C# which creates an excel file. Here is the code
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkBook.CheckCompatibility = false;
xlWorkBook.DoNotPromptForConvert = true;
xlApp.Visible = true; // ensure that the excel app is visible.
xlWorkSheet = (Excel.Worksheet)xlApp.ActiveSheet; // Get the current active worksheet.
Microsoft.Office.Interop.Excel.Worksheet worksheet2 = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2); //Get more work sheet if neccessary
xlWorkSheet.Cells[3, 1] = "Name";
xlWorkBook.SaveAs(filepath + fileName, 51, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlShared, misValue, misValue, misValue, misValue, misValue); //For excel 2007 and above
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit();
Now, the problem is that when i open this file again, then i see that the "Merge & Center" option remains disabled. So, when i opens this file through C# code, then i cannot merge the cells. How can i achieve that ?
Thanks