Exemplo n.º 1
0
        WriteGraphMetricColumnOrderedToWorkbook
        (
            GraphMetricColumnOrdered oGraphMetricColumnOrdered,
            ListObject oTable
        )
        {
            Debug.Assert(oGraphMetricColumnOrdered != null);
            Debug.Assert(oTable != null);
            AssertValid();

            Range oVisibleColumnData;

            // Get the specified column.

            if (!TryGetRequiredColumnInformation(oGraphMetricColumnOrdered,
                                                 oTable, out oVisibleColumnData))
            {
                return;
            }

            // Copy the graph metric values to an array.

            GraphMetricValueOrdered [] aoGraphMetricValuesOrdered =
                oGraphMetricColumnOrdered.GraphMetricValuesOrdered;

            Int32 iRows = aoGraphMetricValuesOrdered.Length;

            Object [,] aoValues = ExcelUtil.GetSingleColumn2DArray(iRows);
            Boolean bStyleSpecified = false;

            for (Int32 i = 0; i < iRows; i++)
            {
                GraphMetricValueOrdered oGraphMetricValueOrdered =
                    aoGraphMetricValuesOrdered[i];

                aoValues[i + 1, 1] = oGraphMetricValueOrdered.Value;

                if (oGraphMetricValueOrdered.Style != null)
                {
                    // A style was specified for this row.  It will need to be
                    // applied later.  (It should be possible to apply the style
                    // here, but that does not work reliably when values are
                    // written to the cells afterwards, as they are after this
                    // loop.)

                    bStyleSpecified = true;
                }
            }

            // Write the array to the column.

            ExcelUtil.SetRangeValues(oVisibleColumnData, aoValues);

            if (bStyleSpecified)
            {
                for (Int32 i = 0; i < iRows; i++)
                {
                    String sStyle = aoGraphMetricValuesOrdered[i].Style;

                    if (sStyle != null)
                    {
                        // This row has a style.  Apply it.

                        ExcelUtil.SetRangeStyle(
                            (Range)oVisibleColumnData.Cells[i + 1, 1], sStyle);
                    }
                }
            }
        }
Exemplo n.º 2
0
        //*************************************************************************
        //  Method: WriteGraphMetricColumnOrderedToWorkbook()
        //
        /// <summary>
        /// Writes a GraphMetricColumnOrdered object to the workbook.
        /// </summary>
        ///
        /// <param name="oGraphMetricColumnOrdered">
        /// The GraphMetricColumnOrdered object to write to the workbook.
        /// </param>
        ///
        /// <param name="oTable">
        /// The table containing the column.
        /// </param>
        //*************************************************************************
        protected void WriteGraphMetricColumnOrderedToWorkbook(
            GraphMetricColumnOrdered oGraphMetricColumnOrdered,
            ListObject oTable
            )
        {
            Debug.Assert(oGraphMetricColumnOrdered != null);
            Debug.Assert(oTable != null);
            AssertValid();

            Range oVisibleColumnData;

            // Get the specified column.

            if ( !TryGetRequiredColumnInformation(oGraphMetricColumnOrdered,
            oTable, out oVisibleColumnData) )
            {
            return;
            }

            // Copy the graph metric values to an array.

            GraphMetricValueOrdered [] aoGraphMetricValuesOrdered =
            oGraphMetricColumnOrdered.GraphMetricValuesOrdered;

            Int32 iRows = aoGraphMetricValuesOrdered.Length;
            Object [,] aoValues = ExcelUtil.GetSingleColumn2DArray(iRows);
            Boolean bStyleSpecified = false;

            for (Int32 i = 0; i < iRows; i++)
            {
            GraphMetricValueOrdered oGraphMetricValueOrdered =
                aoGraphMetricValuesOrdered[i];

            aoValues[i + 1, 1] = oGraphMetricValueOrdered.Value;

            if (oGraphMetricValueOrdered.Style != null)
            {
                // A style was specified for this row.  It will need to be
                // applied later.  (It should be possible to apply the style
                // here, but that does not work reliably when values are
                // written to the cells afterwards, as they are after this
                // loop.)

                bStyleSpecified = true;
            }
            }

            // Write the array to the column.

            ExcelUtil.SetRangeValues(oVisibleColumnData, aoValues);

            if (bStyleSpecified)
            {
            for (Int32 i = 0; i < iRows; i++)
            {
                String sStyle = aoGraphMetricValuesOrdered[i].Style;

                if (sStyle != null)
                {
                    // This row has a style.  Apply it.

                    ExcelUtil.SetRangeStyle(
                        (Range)oVisibleColumnData.Cells[i + 1, 1], sStyle);
                }
            }
            }
        }