/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if ((rowIndex < m_RowCount) && (rowIndex >= 0) && (columnIndex < m_ColumnCount) && (columnIndex >= 0)) { string valueDropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); m_SetOfUsedPropertyIndices.Add(rowIndex); m_Range.CreateDropdownList(rowIndex, columnIndex, valueDropDownListAsString); if (ExcelDataConverter.IsEmptyCell(m_Data[rowIndex, columnIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_Data[rowIndex, columnIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="inputCell">The input Excel cell.</param> /// <param name="value">The value of the Excel cell (output).</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> private ExcelCellValueState TryGetValue <TEnum>(object inputCell, out TEnum value, EnumStringRepresentationUsage enumStringRepresentationUsage) where TEnum : struct, IComparable, IConvertible, IFormattable { object excelCellValue; if (inputCell == null) { value = default(TEnum); return(ExcelCellValueState.NoValidValue); } else if (inputCell is ExcelReference) { ExcelReference excelRange = (ExcelReference)inputCell; string valueDropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); excelRange.CreateDropdownList(0, 0, valueDropDownListAsString); excelCellValue = excelRange.GetValue(); } else { excelCellValue = inputCell; } if (ExcelDataConverter.IsEmptyCell(excelCellValue) == true) { value = default(TEnum); return(ExcelCellValueState.EmptyOrMissingExcelCell); } return((ExcelDataConverter.TryGetCellValue <TEnum>(excelCellValue, enumStringRepresentationUsage, out value) == true) ? ExcelCellValueState.ProperValue : ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell with respect to specific row and column index. /// </summary> /// <typeparam name="T">The type of the output.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="value">The value (output).</param> /// <param name="dataAdvice">Data advice, i.e. a list of possible outcome, perhaps <c>null</c>.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="T"/> represents a enumeration.</exception> public ExcelCellValueState TryGetValue <T>(out T value, int rowIndex, int columnIndex, IExcelDataAdvice dataAdvice = null) { if ((rowIndex < m_RowCount) && (rowIndex >= 0) && (columnIndex < m_ColumnCount) && (columnIndex >= 0)) { m_SetOfUsedPropertyIndices.Add(rowIndex); if (dataAdvice != null) { m_Range.CreateDropdownList(rowIndex, columnIndex, dataAdvice.AsExcelDropDownListString()); } m_GuidedExcelDataQuery.SetDataAdvice(rowIndex, columnIndex, dataAdvice); if (ExcelDataConverter.IsEmptyCell(m_Data[rowIndex, columnIndex]) == true) { value = default(T); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(T)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <T>(m_Data[rowIndex, columnIndex], out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } value = default(T); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell. /// </summary> /// <typeparam name="T">The type of the output.</typeparam> /// <param name="inputCell">The input Excel cell.</param> /// <param name="value">The value of the Excel cell (output).</param> /// <param name="valueDropDownListAsString">The optional semicolon separated <see cref="System.String"/> representation of the /// possible outcomes with respect to <paramref name="value"/>, i.e. if not <c>null</c> a drop down list will be added to the corresponding Excel cell.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> private ExcelCellValueState TryGetValue <T>(object inputCell, out T value, string valueDropDownListAsString) { object excelCellValue; if (inputCell == null) { value = default(T); return(ExcelCellValueState.NoValidValue); } else if (inputCell is ExcelReference) { ExcelReference excelRange = (ExcelReference)inputCell; excelRange.CreateDropdownList(0, 0, valueDropDownListAsString); excelCellValue = excelRange.GetValue(); } else { excelCellValue = inputCell; } if (ExcelDataConverter.IsEmptyCell(excelCellValue) == true) { value = default(T); return(ExcelCellValueState.EmptyOrMissingExcelCell); } return((ExcelDataConverter.TryGetCellValue <T>(excelCellValue, out value) == true) ? ExcelCellValueState.ProperValue : ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell with respect to specific row and column index. /// </summary> /// <typeparam name="T">The type of the output.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="value">The value (output).</param> /// <param name="dataAdvice">Data advice, i.e. a list of possible outcome, perhaps <c>null</c>.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="T"/> represents a enumeration.</exception> public ExcelCellValueState TryGetValue <T>(out T value, int rowIndex, int columnIndex, IExcelDataAdvice dataAdvice = null) { if (typeof(T).IsEnum) { throw new ArgumentException("The type " + typeof(T).ToString() + " represents a enumeration which is not allowed.", "T"); } if ((rowIndex >= 0) && (rowIndex < m_RowCount)) { if (columnIndex == 0) { if (dataAdvice != null) { m_PropertyNames.CreateDropdownList(0, rowIndex, dataAdvice.AsExcelDropDownListString()); } m_SetOfUsedPropertyIndices.Add(rowIndex); m_GuidedExcelDataQuery.SetDataAdvice(rowIndex, columnIndex, dataAdvice); if (ExcelDataConverter.IsEmptyCell(m_PropertyNameArray[0, rowIndex]) == true) { value = default(T); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(T)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <T>(m_PropertyNameArray[0, rowIndex], out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } else if ((columnIndex >= 1) && (columnIndex < m_ColumnCount)) { if (dataAdvice != null) { m_PropertyValues.CreateDropdownList(columnIndex - 1, rowIndex, dataAdvice.AsExcelDropDownListString()); } m_SetOfUsedPropertyIndices.Add(rowIndex); m_GuidedExcelDataQuery.SetDataAdvice(rowIndex, columnIndex, dataAdvice); if (ExcelDataConverter.IsEmptyCell(m_PropertyValueArray[columnIndex - 1, rowIndex]) == true) { value = default(T); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(T)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <T>(m_PropertyValueArray[columnIndex - 1, rowIndex], out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } } value = default(T); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if (typeof(TEnum).IsEnum == false) { throw new ArgumentException("The type " + typeof(TEnum).ToString() + " does not represents a enumeration.", "TEnum"); } if ((rowIndex >= 0) && (rowIndex < m_RowCount)) { string dropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); if (columnIndex == 0) { m_PropertyNames.CreateDropdownList(0, rowIndex, dropDownListAsString); m_SetOfUsedPropertyIndices.Add(rowIndex); if (ExcelDataConverter.IsEmptyCell(m_PropertyNameArray[0, rowIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } if (ExcelDataConverter.TryGetCellValue <TEnum>(m_PropertyNameArray[0, rowIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } else if ((columnIndex >= 1) && (columnIndex < m_ColumnCount)) { m_PropertyValues.CreateDropdownList(columnIndex - 1, rowIndex, dropDownListAsString); m_SetOfUsedPropertyIndices.Add(rowIndex); if (ExcelDataConverter.IsEmptyCell(m_PropertyValueArray[columnIndex - 1, rowIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_PropertyValueArray[columnIndex - 1, rowIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if ((rowIndex < RowCount) && (rowIndex >= 0) && (columnIndex < ColumnCount) && (columnIndex >= 0)) { string valueDropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); if (rowIndex < m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1) // query the header { m_HeaderRange.CreateDropdownList(rowIndex, columnIndex, valueDropDownListAsString); if (ExcelDataConverter.IsEmptyCell(m_HeaderData[rowIndex, columnIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_HeaderData[rowIndex, columnIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } else // query below the header { int adjRowIndex = rowIndex - (m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1); m_BelowHeaderRange.CreateDropdownList(adjRowIndex, columnIndex, valueDropDownListAsString); if (ExcelDataConverter.IsEmptyCell(m_BelowHeaderData[adjRowIndex, columnIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_BelowHeaderData[adjRowIndex, columnIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell with respect to specific row and column index. /// </summary> /// <typeparam name="T">The type of the output.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="value">The value (output).</param> /// <param name="dataAdvice">Data advice, i.e. a list of possible outcome, perhaps <c>null</c>.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="T"/> represents a enumeration.</exception> public ExcelCellValueState TryGetValue <T>(out T value, int rowIndex, int columnIndex, IExcelDataAdvice dataAdvice = null) { if ((rowIndex < RowCount) && (rowIndex >= 0) && (columnIndex < ColumnCount) && (columnIndex >= 0)) { if (dataAdvice != null) { m_HeaderRange.CreateDropdownList(rowIndex, columnIndex, dataAdvice.AsExcelDropDownListString()); } m_GuidedExcelDataQuery.SetDataAdvice(rowIndex, columnIndex, dataAdvice); if (rowIndex < m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1) // query the header { if (ExcelDataConverter.IsEmptyCell(m_HeaderData[rowIndex, columnIndex]) == true) { value = default(T); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(T)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <T>(m_HeaderData[rowIndex, columnIndex], out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } else // query below the header { int adjRowIndex = rowIndex - (m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1); if (ExcelDataConverter.IsEmptyCell(m_BelowHeaderData[adjRowIndex, columnIndex]) == true) { value = default(T); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(T)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <T>(m_BelowHeaderData[adjRowIndex, columnIndex], out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } } value = default(T); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data. /// </returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if ((rowIndex == 0) && (columnIndex == 0)) { if (ExcelDataConverter.IsEmptyCell(m_ExcelCellValue) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(0, 0, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } if (ExcelDataConverter.TryGetCellValue <TEnum>(m_ExcelCellValue, enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(0, 0, value); return(ExcelCellValueState.ProperValue); } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell with respect to specific row and column index. /// </summary> /// <typeparam name="T">The type of the output.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="value">The value (output).</param> /// <param name="dataAdvice">Data advice, i.e. a list of possible outcome, perhaps <c>null</c>.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data. /// </returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="T"/> represents a enumeration.</exception> public ExcelCellValueState TryGetValue <T>(out T value, int rowIndex, int columnIndex, IExcelDataAdvice dataAdvice = null) { if ((rowIndex == 0) && (columnIndex == 0)) { m_GuidedExcelDataQuery.SetDataAdvice(0, 0, dataAdvice); if (ExcelDataConverter.IsEmptyCell(m_ExcelCellValue) == true) { value = default(T); m_GuidedExcelDataQuery.SetData(0, 0, typeof(T)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } if (ExcelDataConverter.TryGetCellValue <T>(m_ExcelCellValue, out value) == true) { m_GuidedExcelDataQuery.SetData(0, 0, value); return(ExcelCellValueState.ProperValue); } } value = default(T); return(ExcelCellValueState.NoValidValue); }