B
Bjacaruso
Merging Cells from C# and Interop
Using Excel 2003 I am trying to merge some cells from C# code:
Code:
Excel.ApplicationClass xApp; //Excel App
Excel.Workbook tWB; //Target Workbook
Excel.Worksheet tWS; //Target Worksheet
Excel.Range tR; //Target Range holder
//Start up Excel
xApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
//Create the new Workbook and get the sheet
tWB = xApp.Workbooks.Add(Type.Missing);
tWB.Worksheets.Add(Type.Missing, Type.Missing, 1,
Excel.XlSheetType.xlWorksheet);
tWS = (Excel.Worksheet)tWB.Worksheets.get_Item(1);
//Report Title
tR = tWS.get_Range("A1", "M1");
tR.Font.Size = 20;
tR.Font.Bold = true;
tR.ShrinkToFit = false;
tR.MergeCells = true;
tR.Value2 = "Summary Revenue Report";
Not sure why the range is never merged, I try the same thing from VBA (using
VBA cade) and it works, but this C# does everything but merge the cells....
Using Excel 2003 I am trying to merge some cells from C# code:
Code:
Excel.ApplicationClass xApp; //Excel App
Excel.Workbook tWB; //Target Workbook
Excel.Worksheet tWS; //Target Worksheet
Excel.Range tR; //Target Range holder
//Start up Excel
xApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
//Create the new Workbook and get the sheet
tWB = xApp.Workbooks.Add(Type.Missing);
tWB.Worksheets.Add(Type.Missing, Type.Missing, 1,
Excel.XlSheetType.xlWorksheet);
tWS = (Excel.Worksheet)tWB.Worksheets.get_Item(1);
//Report Title
tR = tWS.get_Range("A1", "M1");
tR.Font.Size = 20;
tR.Font.Bold = true;
tR.ShrinkToFit = false;
tR.MergeCells = true;
tR.Value2 = "Summary Revenue Report";
Not sure why the range is never merged, I try the same thing from VBA (using
VBA cade) and it works, but this C# does everything but merge the cells....