/// <summary> /// Gets the format for excel cell /// </summary> /// <param name="dc">The dc.</param> /// <returns></returns> public static String GetFormatForExcel(this DataColumn dc) { String format = dc.GetFormat(); Int32 formatN = 0; if (format.isNullOrEmpty()) { return(null); } if (format.Contains("P")) { format = format.Replace("P", ""); formatN = 0; if (!Int32.TryParse(format, out formatN)) { formatN = 3; } format = "0." + "0".Repeat(formatN) + "%"; } else if (format.Contains("D")) { format = format.Replace("D", ""); if (!Int32.TryParse(format, out formatN)) { formatN = 3; } format = "0".Repeat(formatN); } else if (format.Contains("F")) { format = format.Replace("F", ""); if (!Int32.TryParse(format, out formatN)) { formatN = 3; } format = "0." + "0".Repeat(formatN); } else if (format.Contains("T")) { format = format.Replace("T", "h:mm:ss"); } else { } return(format); }
public settingsPropertyEntry(DataColumn dc) { index = dc.Ordinal; priority = dc.Ordinal; displayName = dc.Caption; name = dc.ColumnName; description = dc.GetDesc(); type = dc.DataType; var t = dc.GetValueType(); if (t != typeof(String)) { type = t; } categoryName = dc.GetGroup(); format = dc.GetFormat(); letter = dc.GetLetter(); aggregation = dc.GetAggregation(); //spe.index = dc.Ordinal; importance = dc.GetImportance(); expression = dc.Expression; unit = dc.GetUnit(); textColor = dc.GetTextColor().ColorToHex(); width = dc.GetWidth(); Alignment = dc.GetAligment(); //spe.displayName = dc.Caption; //spe.name = dc.ColumnName; //spe.description = dc.GetDesc(); //spe.type = dc.DataType; //spe.categoryName = dc.GetGroup(); //spe.format = dc.GetFormat(); //spe.letter = dc.GetLetter(); //spe.aggregation = dc.GetAggregation(); ////spe.index = dc.Ordinal; //spe.importance = dc.GetImportance(); //spe.expression = dc.Expression; //spe.unit = dc.GetUnit(); //spe.priority = dc.Ordinal; //spe.width = dc.GetWidth(); color = dc.GetDefaultBackground().ColorToHex(); isHiddenInReport = dc.ExtendedProperties.ContainsKey(imbAttributeName.reporting_hide); setAcceptableValues(); }
public dataValueFormatInfo(DataColumn dc) { directAppend = dc.ExtendedProperties.getProperBoolean(false, templateFieldDataTable.col_directAppend); valueFormat = dc.GetFormat(); importance = dc.GetImportance(); // ExtendedProperties.getProperEnum<dataPointImportance>(dataPointImportance.normal, imbAttributeName.measure_important); Type type = dc.DataType; if (dc.ExtendedProperties.Contains(templateFieldDataTable.col_type)) { type = (Type)dc.ExtendedProperties[templateFieldDataTable.col_type]; } if (dc.DataType.isNumber()) { position = printHorizontal.right; } }
public chartModel BuildDonutChart(DataTable dataTable, String ColumnForLabel, String ColumnForValue) { var output = new chartModel(); DataColumn val = dataTable.Columns[ColumnForValue]; foreach (DataRow dr in dataTable.Rows) { chartDataColumn cdc = new chartDataColumn(dr[ColumnForLabel].ToString(), dr[ColumnForValue]); cdc.dataFormatting = val.GetFormat(); output.data.columns.Add(cdc); } output.data.type = chartTypeEnum.donut; output.chartFormat = new chartTypeFormatting() { axisType = chartTypeEnum.donut, title = dataTable.GetTitle() }; return(output); }
public chartDataColumn(DataColumn source) { columnLabel = source.GetHeading(); dataFormatting = source.GetFormat(); if (!source.GetValueType().isNumber()) { escapeValueFormat = "'{0}'"; } foreach (DataRow dr in source.Table.Rows) { String v = dr[source].toStringSafe("", dataFormatting); if (escapeValueFormat != "{0}") { v = String.Format(escapeValueFormat, v); } columnValues.Add(v); } }
public DataColumnInReportDefinition Add(DataColumnInReportTypeEnum columnType, DataColumn column, dataPointAggregationType aggregation, string unit = "") { DataColumnInReportDefinition output = new DataColumnInReportDefinition(); output.columnType = columnType; output.aggregation = aggregation; output.columnSourceName = column.ColumnName; output.columnPriority = column.GetPriority(); output.format = column.GetFormat(); Type valueType = typeof(string); string name = ""; string description = ""; string letter = ""; switch (aggregation) { default: case dataPointAggregationType.max: case dataPointAggregationType.min: case dataPointAggregationType.sum: case dataPointAggregationType.firstEntry: case dataPointAggregationType.lastEntry: case dataPointAggregationType.range: valueType = column.DataType; break; case dataPointAggregationType.avg: case dataPointAggregationType.stdev: case dataPointAggregationType.var: case dataPointAggregationType.entropy: valueType = typeof(double); if (output.format.isNullOrEmpty()) { output.format = "F5"; } break; case dataPointAggregationType.count: valueType = typeof(int); break; } letter = column.GetLetter(); if (columnType == DataColumnInReportTypeEnum.dataSummed) { if (!letter.isNullOrEmpty()) { letter = aggregation.ToString() + "(" + letter + ")"; } output.columnLetter = letter; output.columnDescription = "(" + aggregation.ToString() + ") of " + column.ColumnName + ". " + column.GetDesc(); } output.columnName = column.ColumnName + " (" + aggregation.ToString() + ")"; output.columnSourceName = column.ColumnName; output.importance = column.GetImportance(); output.columnUnit = column.GetUnit(); output.columnValueType = valueType; output.columnDefault = valueType.GetDefaultValue(); output.columnGroup = column.GetGroup(); output.spe = column.GetSPE(); Add(column.ColumnName, output); return(output); }