コード例 #1
0
ファイル: XlsDef.cs プロジェクト: tilekchubakov/CISSA
        public void WriteTo(XlsWriter writer)
        {
            var oldStyle = writer.SetStyle(Style);

            try
            {
                if (DefaultRowHeight > 0)
                {
                    writer.DefaultRowHeight = DefaultRowHeight;
                }

                if (ColumnWidths != null)
                {
                    foreach (var columnWidth in ColumnWidths)
                    {
                        writer.SetColumnWidth(columnWidth.Key - 1, columnWidth.Value * 256);
                    }
                }
                foreach (var area in Areas)
                {
                    area.WriteTo(writer);
                }
                writer.ApplyColumnAutoSize();
            }
            catch (Exception e)
            {
                Logger.OutputLog("XlsDef", e, "Excel Report Writing");
                throw;
            }
            finally
            {
                writer.Style = oldStyle;
            }
        }
コード例 #2
0
ファイル: XlsDateTime.cs プロジェクト: tilekchubakov/CISSA
        public override void WriteTo(XlsWriter writer, int param = 0)
        {
            var oldStyle = writer.MergeStyle(Style);

            try
            {
                //writer.SetBorder(BorderTop, BorderLeft, BorderRight, BorderBottom);
                writer.AddCell(ColSpan, RowSpan);
                writer.SetValue(Value);
                if (Width != null)
                {
                    writer.SetColumnWidth((int)Width);
                }
            }
            finally
            {
                writer.Style = oldStyle;
            }
        }
コード例 #3
0
ファイル: XlsDataField.cs プロジェクト: tilekchubakov/CISSA
        public override void WriteTo(XlsWriter writer, int param = 0)
        {
            var oldStyle = writer.MergeStyle(Style);

            try
            {
                var value = param == XlsGrid.WriteSummaryRow
                    ? SummaryValueCount > 0 ? GetSummaryValue() : ""
                    : GetValue();
                var type = Field.GetDataType();

                // writer.SetBorder(BorderTop, BorderLeft, BorderRight, BorderBottom);
                writer.ShrinkToFit = ShrinkToFit;
                writer.AddCell(ColSpan, RowSpan);

                if (value != null)
                {
                    var s = value.ToString();
                    if (type == BaseDataType.Int)
                    {
                        int i;
                        if (value is int)
                        {
                            writer.SetValue((int)value);
                            SummaryValue += (int)value;
                            SummaryValueCount++;
                        }
                        else if (int.TryParse(s, out i))
                        {
                            writer.SetValue(i);
                            SummaryValue += i;
                            SummaryValueCount++;
                        }
                        else
                        {
                            writer.SetValue(s);
                        }
                    }
                    else if (type == BaseDataType.Float || type == BaseDataType.Currency)
                    {
                        double d;
                        if (value is double)
                        {
                            writer.SetValue((double)value);
                            SummaryValue += (double)value;
                            SummaryValueCount++;
                        }
                        else if (value is float)
                        {
                            d = Convert.ToDouble(value);
                            writer.SetValue(d);
                            SummaryValue += d;
                            SummaryValueCount++;
                        }
                        else if (value is decimal)
                        {
                            d = Convert.ToDouble(value);
                            writer.SetValue(d);
                            SummaryValue += d;
                            SummaryValueCount++;
                        }
                        else if (value is int)
                        {
                            d = Convert.ToDouble(value);
                            writer.SetValue(d);
                            SummaryValue += d;
                            SummaryValueCount++;
                        }
                        else if (double.TryParse(s, out d))
                        {
                            writer.SetValue(d);
                            SummaryValue += d;
                            SummaryValueCount++;
                        }
                        else
                        {
                            writer.SetValue(s);
                        }
                    }
                    else if (type == BaseDataType.DateTime)
                    {
                        DateTime dt;
                        if (value is DateTime)
                        {
                            writer.SetValue((DateTime)value);
                        }
                        else if (DateTime.TryParse(s, out dt))
                        {
                            writer.SetValue(dt);
                        }
                        else
                        {
                            writer.SetValue(s);
                        }
                    }
                    else if (type == BaseDataType.Bool)
                    {
                        bool b;
                        if (value is bool)
                        {
                            writer.SetValue((bool)value);
                        }
                        else if (bool.TryParse(s, out b))
                        {
                            writer.SetValue(b);
                        }
                        else
                        {
                            writer.SetValue(s);
                        }
                    }
                    else
                    {
                        writer.SetValue(s);
                    }

                    /*{
                     *  case CissaDataType.Text:
                     *      writer.SetValue(value.ToString());
                     *      break;
                     *  case CissaDataType.Int:
                     *      writer.SetValue((int) value);
                     *      break;
                     *  case CissaDataType.Float:
                     *      writer.SetValue((double) value);
                     *      break;
                     *  case CissaDataType.Currency:
                     *      writer.SetValue(Convert.ToDouble(value));
                     *      break;
                     *  case CissaDataType.DateTime:
                     *      writer.SetValue((DateTime) value);
                     *      break;
                     *  case CissaDataType.Bool:
                     *      writer.SetValue((bool) value);
                     *      break;
                     *  default:
                     *      writer.SetValue(value);
                     *      break;
                     * }*/
                }
                if (Width != null)
                {
                    writer.SetColumnWidth((int)Width);
                }
            }
            finally
            {
                writer.Style = oldStyle;
            }
        }