Archive

Posts Tagged ‘Excel COM Interop’

Excel COM Interoperability – Cell Borders

March 11, 2010 Leave a comment

Hi All,

This code was hard to find on the net but here is how you set borders on a cell in c# using COM Interop.

Range cells = sheet.get_Range(String.Format("{0}{1}","A", 1), String.Format("{0}{1}", "A", 2));
cells.BorderAround(Type.Missing, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, Type.Missing);

Feels Pretty dirty but hope it helps you..

Blair…

Categories: Development Tags: , ,

Excel COM Interoperability – Cell Color

March 11, 2010 Leave a comment

Hi All,

This code was hard to find on the net but here is how you set the background color of a cell in c# using COM Interop.

Range cells = sheet.get_Range(String.Format("{0}{1}","A", 1), String.Format("{0}{1}", "A", 2));
cells.Interior.Color = ColorTranslator.ToOle(Color.Beige)

Feels Pretty dirty but hope it helps you..

Blair…

Categories: Development Tags: , ,

Excel COM Interop and Freeze Panes

February 25, 2010 6 comments

This took me so long to get working. The code below sets the freeze pane on a sheet to the 2nd column. Hope this helps someone.

        private void SetupFreezePaneForSheet(_Worksheet sheet)
        {
            sheet.Activate();
            sheet.Application.ActiveWindow.SplitColumn = 2;
            sheet.Application.ActiveWindow.FreezePanes = true;
        }
Categories: Development Tags: , ,