Ejemplo n.º 1
0
        protected internal string GetValueForExcelExport(ExcelColumn col, BaseRecord rec)
        {
            String val = "";
            bool isNull = false;
            decimal deciNumber;

            if (col == null)
                return null;
            //DFKA value is evaluated in the <tablename>ExportExcelButton_Click method in the <tablename>.controls file
            //if (col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn))
            //{
            //    //  Foreign Key column, so we will use DFKA and String type.
            //    val = rec.Format(col.DisplayColumn);
            //}
            //else
            //{
                switch (col.DisplayColumn.ColumnType)
                {

                    case BaseColumn.ColumnTypes.Number:
                    case BaseColumn.ColumnTypes.Percentage:
                    case BaseColumn.ColumnTypes.Currency:
                        ColumnValue numVal = rec.GetValue(col.DisplayColumn);
                        //If the value of the column to be exported is nothing, add an empty cell to the Excel file
                        if (numVal.IsNull)
                        {
                            isNull = true;
                        }
                        else
                        {
                            deciNumber = numVal.ToDecimal();
                            val = deciNumber.ToString(System.Globalization.CultureInfo.InvariantCulture);

                            if (col.DisplayColumn.ColumnType == BaseColumn.ColumnTypes.Currency)
                            {
                                val = rec.Format(col.DisplayColumn, "c");
                            }
                            else if (col.DisplayColumn.ColumnType == BaseColumn.ColumnTypes.Percentage)
                            {
                                val = rec.Format(col.DisplayColumn, "F2");
                            } else if (col.DisplayFormat == "Standard")
                            {
                                val = rec.Format(col.DisplayColumn, "F2");
                            }
                        }
                        break;
                    case BaseColumn.ColumnTypes.Date:
                        ColumnValue dateVal = rec.GetValue(col.DisplayColumn);
                        if (dateVal.IsNull)
                        {
                            isNull = true;
                        }
                        else
                        {  // Specify the default Excel format for the date field
                            // val = rec.Format(col.DisplayColumn, "s");
                            // val += ".000";
                            val = rec.Format(col.DisplayColumn, "d");
                        }
                        break;
                    case BaseColumn.ColumnTypes.Very_Large_String:
                        val = rec.GetValue(col.DisplayColumn).ToString();
                        break;

                    case BaseColumn.ColumnTypes.Boolean:
                        val = rec.Format(col.DisplayColumn);
                        break;

                    default:
                        val = rec.Format(col.DisplayColumn);
                        break;
                }
            //}
            if (isNull)
                return null;
            else
                return val;
        }
Ejemplo n.º 2
0
        public int GetExcelCellWidth(ExcelColumn col)
        {
            if (col == null)
                return 0;

            int width = 50;
            if (col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn))
            {
                // Set width if field is a foreign key field
                width = 100;
            }
            else
            {
                switch (col.DisplayColumn.ColumnType)
                {
                    case BaseColumn.ColumnTypes.Binary:
                    case BaseColumn.ColumnTypes.Image:
                        //  Skip - do nothing for these columns
                        width = 0;
                        break;
                    case BaseColumn.ColumnTypes.Currency:
                    case BaseColumn.ColumnTypes.Number:
                    case BaseColumn.ColumnTypes.Percentage:
                        width = 60;
                        break;
                    case BaseColumn.ColumnTypes.String:
                        width = 255;
                        break;
                    case BaseColumn.ColumnTypes.Very_Large_String:
                        width = 255;
                        break;
                    default:
                        width = 50;
                        break;
                }
            }
            return width;
        }
Ejemplo n.º 3
0
        //return true if type can be included in export data
        protected internal ISDDataType GetExcelDataType(ExcelColumn col)
        {
            if (col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn))
                return ISDDataType.ISDString;

            switch (col.DisplayColumn.ColumnType)
            {
                case BaseColumn.ColumnTypes.Number:
                case BaseColumn.ColumnTypes.Percentage:
                    return ISDDataType.ISDNumber;

                case BaseColumn.ColumnTypes.Currency:
                    return ISDDataType.ISDNumber;

                case BaseColumn.ColumnTypes.Date:
                    return ISDDataType.ISDDateTime;

                case BaseColumn.ColumnTypes.Very_Large_String:
                    return ISDDataType.ISDString;

                case BaseColumn.ColumnTypes.Boolean:
                    return ISDDataType.ISDString;

                default:
                    return ISDDataType.ISDString;
            }
        }
Ejemplo n.º 4
0
 public string GetDisplayFormat(ExcelColumn col)
 {
     return col.DisplayFormat;
 }
Ejemplo n.º 5
0
 public void AddColumn(ExcelColumn col)
 {
     data.ColumnList.Add(col);
 }
Ejemplo n.º 6
0
        public bool IsString(ExcelColumn col)
        {
            if (col == null)
                return false;

            return IsString(col.DisplayColumn);
        }
Ejemplo n.º 7
0
        public bool IncludeInExport(ExcelColumn col)
        {
            if (col == null)
                return false;

            return IncludeInExport(col.DisplayColumn);
        }
Ejemplo n.º 8
0
 public void AddColumn(ExcelColumn col)
 {
     if (_exportDataToExcel != null)
             _exportDataToExcel.AddColumn(col);
 }