Example #1
0
        /// <summary>
        /// draw border color
        /// </summary>
        /// <param name="xSheet"></param>
        /// <param name="aRange"></param>
        /// <param name="width"></param>
        /// <param name="color"></param>
        public void setBorderColor(unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange, short width, int color)
        {
            unoidl.com.sun.star.beans.XPropertySet xPropSet   = null;
            unoidl.com.sun.star.table.XCellRange   xCellRange = null;

            // draw border
            xCellRange = xSheet.getCellRangeByName(aRange);
            xPropSet   = (unoidl.com.sun.star.beans.XPropertySet)xCellRange;
            unoidl.com.sun.star.table.BorderLine aLine =
                new unoidl.com.sun.star.table.BorderLine();
            aLine.Color          = color;
            aLine.InnerLineWidth = aLine.LineDistance = 0;
            aLine.OuterLineWidth = width;

            unoidl.com.sun.star.table.TableBorder aBorder =
                new unoidl.com.sun.star.table.TableBorder();
            aBorder.TopLine         = aBorder.BottomLine = aBorder.LeftLine =
                aBorder.RightLine   = aLine;
            aBorder.IsTopLineValid  = aBorder.IsBottomLineValid = true;
            aBorder.IsLeftLineValid = aBorder.IsRightLineValid = true;
            xPropSet.setPropertyValue(
                "TableBorder",
                new uno.Any(
                    typeof(unoidl.com.sun.star.table.TableBorder), aBorder));
        }
Example #2
0
        /** Draws a colored border around the range and writes the headline
         *  in the first cell.
         *
         *  @param xSheet  The XSpreadsheet interface of the spreadsheet.
         *  @param aRange  The address of the cell range (or a named range).
         *  @param aHeadline  The headline text. */
        public void prepareRange(
            unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
            String aRange, String aHeadline)
        {
            unoidl.com.sun.star.beans.XPropertySet xPropSet   = null;
            unoidl.com.sun.star.table.XCellRange   xCellRange = null;

            // draw border
            xCellRange = xSheet.getCellRangeByName(aRange);
            xPropSet   = (unoidl.com.sun.star.beans.XPropertySet)xCellRange;
            unoidl.com.sun.star.table.BorderLine aLine =
                new unoidl.com.sun.star.table.BorderLine();
            aLine.Color          = 0x99CCFF;
            aLine.InnerLineWidth = aLine.LineDistance = 0;
            aLine.OuterLineWidth = 100;

            unoidl.com.sun.star.table.TableBorder aBorder =
                new unoidl.com.sun.star.table.TableBorder();
            aBorder.TopLine         = aBorder.BottomLine = aBorder.LeftLine =
                aBorder.RightLine   = aLine;
            aBorder.IsTopLineValid  = aBorder.IsBottomLineValid = true;
            aBorder.IsLeftLineValid = aBorder.IsRightLineValid = true;
            xPropSet.setPropertyValue(
                "TableBorder",
                new uno.Any(
                    typeof(unoidl.com.sun.star.table.TableBorder), aBorder));

            // draw headline
            unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
                (unoidl.com.sun.star.sheet.XCellRangeAddressable)xCellRange;
            unoidl.com.sun.star.table.CellRangeAddress aAddr =
                xAddr.getRangeAddress();

            xCellRange = xSheet.getCellRangeByPosition(
                aAddr.StartColumn,
                aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow);

            xPropSet = (unoidl.com.sun.star.beans.XPropertySet)xCellRange;
            xPropSet.setPropertyValue(
                "CellBackColor", new uno.Any((Int32)0x99CCFF));
            // write headline
            unoidl.com.sun.star.table.XCell xCell =
                xCellRange.getCellByPosition(0, 0);
            xCell.setFormula(aHeadline);
            xPropSet = (unoidl.com.sun.star.beans.XPropertySet)xCell;
            xPropSet.setPropertyValue(
                "CharColor", new uno.Any((Int32)0x003399));
            xPropSet.setPropertyValue(
                "CharWeight",
                new uno.Any((Single)unoidl.com.sun.star.awt.FontWeight.BOLD));
        }
Example #3
0
        /** Draws a colored border around the range and writes the headline
        in the first cell.

        @param xSheet  The XSpreadsheet interface of the spreadsheet.
        @param aRange  The address of the cell range (or a named range).
        @param aHeadline  The headline text. */
        public void prepareRange(
        unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
        String aRange, String aHeadline )
        {
            unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
            unoidl.com.sun.star.table.XCellRange xCellRange = null;

            // draw border
            xCellRange = xSheet.getCellRangeByName( aRange );
            xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
            unoidl.com.sun.star.table.BorderLine aLine =
            new unoidl.com.sun.star.table.BorderLine();
            aLine.Color = 0x99CCFF;
            aLine.InnerLineWidth = aLine.LineDistance = 0;
            aLine.OuterLineWidth = 100;
            unoidl.com.sun.star.table.TableBorder aBorder =
            new unoidl.com.sun.star.table.TableBorder();
            aBorder.TopLine = aBorder.BottomLine = aBorder.LeftLine =
            aBorder.RightLine = aLine;
            aBorder.IsTopLineValid = aBorder.IsBottomLineValid = true;
            aBorder.IsLeftLineValid = aBorder.IsRightLineValid = true;
            xPropSet.setPropertyValue(
            "TableBorder",
            new uno.Any(
                typeof (unoidl.com.sun.star.table.TableBorder), aBorder ) );

            // draw headline
            unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
            (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
            unoidl.com.sun.star.table.CellRangeAddress aAddr =
            xAddr.getRangeAddress();

            xCellRange = xSheet.getCellRangeByPosition(
            aAddr.StartColumn,
            aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow );

            xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
            xPropSet.setPropertyValue(
            "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) );
            // write headline
            unoidl.com.sun.star.table.XCell xCell =
            xCellRange.getCellByPosition( 0, 0 );
            xCell.setFormula( aHeadline );
            xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell;
            xPropSet.setPropertyValue(
            "CharColor", new uno.Any( (Int32) 0x003399 ) );
            xPropSet.setPropertyValue(
            "CharWeight",
            new uno.Any( (Single) unoidl.com.sun.star.awt.FontWeight.BOLD ) );
        }