Пример #1
0
 public void Insert(XlInsertShiftDirection shift, XlInsertFormatOrigin copyOrigin)
 {
     object[] paramArray = new object[2];
     paramArray[0] = shift;
     paramArray[1] = copyOrigin;
     InstanceType.InvokeMember("Insert", BindingFlags.InvokeMethod, null, ComReference, paramArray, XlLateBindingApiSettings.XlThreadCulture);
 }
Пример #2
0
        public static void AddColumnToSheet(
            ref Worksheet ws,
            int columnNumber,
            int columnWidth,
            bool columnWrapText,
            string columnNumberFormat,
            XlDirection shiftDirection,
            XlInsertFormatOrigin insertFormatOrigin,
            int headerRow,
            string headerTitle  = "",
            int headerFontSize  = cHeaderFontSize,
            MakeBold headerBold = MakeBold.Yes,
            XlUnderlineStyle headerUnderline   = XlUnderlineStyle.xlUnderlineStyleSingle,
            WrapText headerWrapText            = WrapText.Yes,
            XlHAlign headerHorizontalAlignment = XlHAlign.xlHAlignCenter,
            int headerOrientation = 0)
        {
            // Insert the new column and apply things that pertain to all cells in the column
            //((Range)ws.Columns[columnNumber]).Insert(Shift: shiftDirection, CopyOrigin: insertFormatOrigin);

            Range newColumn = (Range)ws.Columns[columnNumber];

            newColumn.Insert(Shift: shiftDirection, CopyOrigin: insertFormatOrigin);
            newColumn.WrapText     = columnWrapText;
            newColumn.NumberFormat = columnNumberFormat;

            // Pass all the rest on
            AddColumnHeaderToSheet(ref ws,
                                   columnNumber,
                                   columnWidth,
                                   headerRow,
                                   headerTitle,
                                   headerFontSize,
                                   headerBold,
                                   headerUnderline,
                                   headerWrapText,
                                   headerHorizontalAlignment,
                                   headerOrientation);
        }