Example #1
0
        /// <summary>Initializes a new instance of the <see cref="GuidedExcelDataQuery"/> class.
        /// </summary>
        /// <param name="guidedExcelDataQuery">The guided excel data query.</param>
        /// <remarks>This copy constructor creates a deep copy of its argument.</remarks>
        protected GuidedExcelDataQuery(GuidedExcelDataQuery guidedExcelDataQuery)
        {
            if (guidedExcelDataQuery == null)
            {
                throw new ArgumentNullException("guidedExcelDataQuery");
            }
            m_Name        = guidedExcelDataQuery.m_Name;
            m_ColumnCount = guidedExcelDataQuery.m_ColumnCount;
            m_Data        = new List <object[]>();
            m_DataAdvice  = new Dictionary <int, IExcelDataAdvice>();
            for (int j = 0; j < guidedExcelDataQuery.m_Data.Count; j++)
            {
                object[] newRow = new object[m_ColumnCount];
                object[] row    = guidedExcelDataQuery.m_Data[j];
                for (int k = 0; k < m_ColumnCount; k++)
                {
                    newRow[k] = row[k];
                }
                m_Data.Add(newRow);
            }

            // we assume that the values of the data advice are value types:
            foreach (var keyValuePair in guidedExcelDataQuery.m_DataAdvice)
            {
                m_DataAdvice.Add(keyValuePair.Key, keyValuePair.Value);
            }
        }
        /// <summary>Initializes a new instance of the <see cref="ExcelTableQueryRegular"/> class.
        /// </summary>
        /// <param name="excelReference">The Excel Range.</param>
        /// <param name="excelDataQueryName">The name of the Excel data query.</param>
        /// <exception cref="ArgumentException">Thrown, if the value of <paramref name="excelReference"/> is not
        /// represented by an two-dimensional array.</exception>
        public ExcelTableQueryRegular(ExcelReference excelReference, string excelDataQueryName)
        {
            if (excelReference == null)
            {
                throw new ArgumentNullException("excelRangeValue");
            }
            m_Range = excelReference;
            object value = m_Range.GetValue();

            if (value is object[, ])
            {
                m_Data        = (object[, ])value;
                m_RowCount    = m_Data.GetLength(0);
                m_ColumnCount = m_Data.GetLength(1);
            }
            else
            {
                throw new ArgumentException("excelRangeValue");
            }

            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            m_Name = new IdentifierString(excelDataQueryName);
            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, rowCount: m_RowCount, columnCount: m_ColumnCount);
        }
Example #3
0
        /// <summary>Initializes a new instance of the <see cref="ExcelPropertyQueryColumnWise"/> class.
        /// </summary>
        /// <param name="propertyNames">The Excel Range (exactly one column) which contains a list of property names.</param>
        /// <param name="propertyValues">The Excel range (exactly one column) which contains the values of the properties.</param>
        /// <param name="excelDataQueryName">The name of the Excel data query.</param>
        internal ExcelPropertyQueryColumnWise(ExcelReference propertyNames, ExcelReference propertyValues, string excelDataQueryName)
        {
            if (propertyNames == null)
            {
                throw new ArgumentNullException("propertyNames");
            }
            m_PropertyNames = propertyNames;

            if (propertyValues == null)
            {
                throw new ArgumentNullException("propertyValues");
            }
            m_PropertyValues = propertyValues;

            m_PropertyNameArray  = (object[, ])propertyNames.GetValue();
            m_PropertyValueArray = (object[, ])propertyValues.GetValue();

            m_RowCount    = m_PropertyNameArray.GetLength(1);
            m_ColumnCount = m_PropertyValueArray.GetLength(0) + 1;
            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            m_Name = new IdentifierString(excelDataQueryName);
            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, m_ColumnCount, m_RowCount);
        }
        /// <summary>Initializes a new instance of the <see cref="ExcelCellQueryPlain"/> class.
        /// </summary>
        /// <param name="excelCell">The excel cell.</param>
        /// <param name="excelDataQueryName">The name of the Excel data query.</param>
        public ExcelCellQueryPlain(object excelCell, string excelDataQueryName)
        {
            m_ExcelCellValue = excelCell;

            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            m_Name = new IdentifierString(excelDataQueryName);
            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, rowCount: 1, columnCount: 1);
        }
Example #5
0
        ///<summary>Initializes a new instance of the <see cref="ExcelTableQueryPlain"/> class.
        ///</summary>
        ///<param name="excelRangeValue">The value of the Excel Range.</param>
        ///<param name="excelDataQueryName">The name of the Excel data query.</param>
        ///<exception cref="ArgumentNullException">Thrown, if one of the arguments is <c>null</c>.</exception>
        public ExcelTableQueryPlain(object[,] excelRangeValue, string excelDataQueryName)
        {
            if (excelRangeValue == null)
            {
                throw new ArgumentNullException("excelRangeValue");
            }
            m_Data        = excelRangeValue;
            m_RowCount    = m_Data.GetLength(0);
            m_ColumnCount = m_Data.GetLength(1);

            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            m_Name = new IdentifierString(excelDataQueryName);
            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, rowCount: m_RowCount, columnCount: m_ColumnCount);
        }
Example #6
0
        /// <summary>Initializes a new instance of the <see cref="ExcelCellQuery"/> class.
        /// </summary>
        /// <param name="excelReference">The Excel Range.</param>
        /// <param name="excelDataQueryName">The name of the Excel data query.</param>
        public ExcelCellQuery(ExcelReference excelReference, string excelDataQueryName)
        {
            if (excelReference == null)
            {
                throw new ArgumentNullException("excelRangeValue");
            }
            m_Range          = excelReference;
            m_ExcelCellValue = m_Range.GetValue();

            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            m_Name = new IdentifierString(excelDataQueryName);

            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, rowCount: 1, columnCount: 1);
        }
Example #7
0
        /// <summary>Initializes a new instance of the <see cref="ExcelTableQueryHeader"/> class.
        /// </summary>
        /// <param name="excelReference">The Excel Range ('header').</param>
        /// <param name="excelDataQueryName">The name of the Excel data query.</param>
        /// <param name="maxRowCount">The maximal number of rows to take into account.</param>
        /// <exception cref="ArgumentException">Thrown, if the value of <paramref name="excelReference"/> is not represented by an two-dimensional array (for example a single row header) or a <see cref="System.String"/>.</exception>
        public ExcelTableQueryHeader(ExcelReference excelReference, string excelDataQueryName, int maxRowCount)
        {
            if (excelReference == null)
            {
                throw new ArgumentNullException("excelRangeValue");
            }

            m_HeaderRange      = excelReference;
            m_BelowHeaderRange = new ExcelReference(m_HeaderRange.RowFirst + 1, maxRowCount - m_HeaderRange.RowLast - 1, m_HeaderRange.ColumnFirst, m_HeaderRange.ColumnLast, m_HeaderRange.SheetId);

            var value = m_HeaderRange.GetValue();

            if (value is object[, ])
            {
                m_HeaderData = (object[, ])value;
                RowCount     = m_HeaderData.GetLength(0);
                ColumnCount  = m_HeaderData.GetLength(1);
            }
            else if (value is String)
            {
                m_HeaderData       = new object[1, 1];
                m_HeaderData[0, 0] = value as String;
                ColumnCount        = 1;
            }
            else
            {
                throw new ArgumentException("excelRangeValue");
            }
            RowCount          = (m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1) + (m_BelowHeaderRange.RowLast - m_BelowHeaderRange.RowFirst + 1);
            m_BelowHeaderData = m_BelowHeaderRange.GetValue() as object[, ];

            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            Name = LongName = new IdentifierString(excelDataQueryName);
            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, rowCount: RowCount, columnCount: ColumnCount);
        }
        /// <summary>Initializes a new instance of the <see cref="ExcelPropertyQuerySingle"/> class.
        /// </summary>
        /// <param name="propertyName">The name of the property.</param>
        /// <param name="propertyValue">The value of the property.</param>
        /// <param name="excelDataQueryName">The name of the Excel data query.</param>
        public ExcelPropertyQuerySingle(object propertyName, object propertyValue, string excelDataQueryName)
        {
            if (propertyName == null)
            {
                throw new ArgumentNullException("propertyName");
            }
            if (propertyValue == null)
            {
                throw new ArgumentNullException("propertyValue");
            }
            if (((propertyName is String) == false) && ((propertyName is ExcelReference) == false))
            {
                throw new ArgumentException("Invalid Property name input.");
            }
            m_PropertyName  = propertyName;
            m_PropertyValue = propertyValue;

            if (excelDataQueryName == null)
            {
                throw new ArgumentNullException("excelDataQueryName");
            }
            m_Name = new IdentifierString(excelDataQueryName);
            m_GuidedExcelDataQuery = new GuidedExcelDataQuery(excelDataQueryName, rowCount: 1);
        }
Example #9
0
 /// <summary>Gets a specific <see cref="GuidedExcelDataQuery"/> which is part of the input for the construction of <see cref="ExcelPoolItem.Value"/>.
 /// </summary>
 /// <param name="name">The name of the <see cref="GuidedExcelDataQuery"/> to search.</param>
 /// <param name="dataQuery">The <see cref="GuidedExcelDataQuery"/> object (output).</param>
 /// <returns>A value indicating whether <paramref name="dataQuery"/> contains valid data.</returns>
 public bool TryGetDataQuery(string name, out GuidedExcelDataQuery dataQuery)
 {
     return(m_ExcelDataQueries.TryGetValue(name, out dataQuery));
 }