BExIS.IO.Transform.Output.ExcelWriter.VariableValueToCell C# (CSharp) Метод

VariableValueToCell() защищенный Метод

Convert a VariableValue to Cell
protected VariableValueToCell ( VariableValue variableValue, int rowIndex, int columnIndex ) : Cell
variableValue BExIS.Dlm.Entities.Data.VariableValue
rowIndex int
columnIndex int
Результат Cell
        protected Cell VariableValueToCell(VariableValue variableValue, int rowIndex, int columnIndex)
        {
            string message = "row :" + rowIndex + "column:" + columnIndex;
            Debug.WriteLine(message);

            DataContainerManager CM = new DataContainerManager();
            DataAttribute dataAttribute = CM.DataAttributeRepo.Get(variableValue.DataAttribute.Id);

            string cellRef = getColumnIndex(columnIndex);

            Cell cell = new Cell();
            cell.CellReference = cellRef;
            cell.StyleIndex = getExcelStyleIndex(dataAttribute.DataType.SystemType, styleIndexArray);
            //cell.DataType = new EnumValue<CellValues>(getExcelType(dataAttribute.DataType.SystemType));
            //cell.CellValue = new CellValue(variableValue.Value.ToString());

            CellValues cellValueType = getExcelType(dataAttribute.DataType.SystemType);
            object value = variableValue.Value;

            if (value != null && !(value is DBNull) && cellValueType == CellValues.Number)
            {
                cell.DataType = new EnumValue<CellValues>(CellValues.Number);

                try
                {
                    if (value != "")
                    {
                        double d = Convert.ToDouble(value, System.Globalization.CultureInfo.InvariantCulture);
                        cell.CellValue = new CellValue(d.ToString(System.Globalization.CultureInfo.InvariantCulture));
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message + "\n|"+message);
                }

                return cell;
            }
            else
            {
                if (value != null && !(value is DBNull) && cellValueType == CellValues.Date)
                {

                    cell.DataType = new EnumValue<CellValues>(CellValues.Number);
                    //CultureInfo provider = CultureInfo.InvariantCulture;
                    try
                    {
                        if (value != "")
                        {
                            DateTime dt = Convert.ToDateTime(value.ToString());
                            cell.CellValue = new CellValue(dt.ToOADate().ToString());
                        }
                    }
                    catch(Exception ex)
                    {
                        throw new Exception(ex.Message + "|" + message);
                    }
                }
                else
                {
                    cell.DataType = new EnumValue<CellValues>(CellValues.String);
                    if(value==null)
                        cell.CellValue = new CellValue("");
                    else
                        cell.CellValue = new CellValue(value.ToString());
                }
            }

            return cell;
        }