Пример #1
0
 public static String RenderReport(Report rep, IHtmlReportTheme theme, Dictionary <String, HtmlCellStyle> stylesheet)
 {
     using (var sw = new StringWriter())
         using (var hw = new HtmlTextWriter(sw))
         {
             var renderer = new HtmlReportWriter(hw);
             renderer.Render(rep, theme, stylesheet);
             return(sw.ToString());
         }
 }
Пример #2
0
 public static String RenderReport(Report rep, IHtmlReportTheme theme, Dictionary<String, HtmlCellStyle> stylesheet)
 {
     using (var sw = new StringWriter())
     using (var hw = new HtmlTextWriter(sw))
     {
         var renderer = new HtmlReportWriter(hw);
         renderer.Render(rep, theme, stylesheet);
         return sw.ToString();
     }
 }
Пример #3
0
        public void Render(Report rep, IHtmlReportTheme theme, Dictionary <String, HtmlCellStyle> stylesheet)
        {
            report = rep;

            html.e("table").att("cellpadding", 0).att("cellspacing", 0);
            html.nl();
            html.e("tbody");
            html.nl();

            row = -1;
            tro = false;
            col = -1;

            List <HtmlCellStyle> styleCache = new List <HtmlCellStyle>();

            foreach (var v in Enum.GetValues(typeof(CellStyleIndex)))
            {
                styleCache.Add(theme != null ? theme.GetStyle((CellStyleIndex)v) : null);
            }

            merged  = new HashSet <int>();
            colSpan = new Dictionary <int, int>();
            rowSpan = new Dictionary <int, int>();

            if (report.MergedCells != null)
            {
                foreach (var mc in report.MergedCells)
                {
                    for (int c = mc.Col1; c <= mc.Col2; c++)
                    {
                        for (int r = mc.Row1; r <= mc.Row2; r++)
                        {
                            merged.Add(CellIndex(r, c));
                        }
                    }
                    int ci = CellIndex(mc.Row1, mc.Col1);
                    merged.Remove(ci);
                    if (mc.Col2 > mc.Col1)
                    {
                        colSpan.Add(ci, mc.Col2 - mc.Col1 + 1);
                    }
                    if (mc.Row2 > mc.Row1)
                    {
                        rowSpan.Add(ci, mc.Row2 - mc.Row1 + 1);
                    }
                }
            }
            if (rep.Cells != null)
            {
                foreach (var cell in report.Cells)
                {
                    if (cell.Row != row)
                    {
                        CompleteRow();
                        StartRow(cell.Row, cell.Column);
                    }
                    ExtendRow(cell.Column);
                    var ind = CellIndex(cell.Row, cell.Column);
                    if (!Merged(ind))
                    {
                        html.td();
                        CheckMergeOrigin(ind);
                        HtmlCellStyle style = null;

                        if (String.IsNullOrEmpty(cell.CellStyleName) || stylesheet == null || !stylesheet.TryGetValue(cell.CellStyleName, out style))
                        {
                            style = styleCache[(int)cell.CellStyleIndex];
                        }

                        String css    = null;
                        String styles = null;
                        if (style != null)
                        {
                            if (style.CssClass != null)
                            {
                                css = style.CssClass;
                            }
                            if (style.Style != null)
                            {
                                styles = style.Style;
                            }
                        }

                        if (cell.CustomStyle != null)
                        {
                            styles += (styles != null ? " " : "") + HtmlCellStyle.BuildHtmlStyle(cell.CustomStyle);
                        }

                        html.attCls(css);
                        html.attStyle(styles);

                        switch (cell.Alignment)
                        {
                        case CellAlignment.Left:
                            html.att("align", "left");
                            break;

                        case CellAlignment.Right:
                            html.att("align", "right");
                            break;

                        case CellAlignment.Center:
                            html.att("align", "center");
                            break;
                        }
                        if (String.IsNullOrEmpty(cell.FormattedValue))
                        {
                            html.nbsp();
                        }
                        else
                        {
                            html.text(cell.FormattedValue, HtmlEncode);
                        }
                        html.c(); //td
                    }
                }
            }

            CompleteRow();
            html.c(); //tbody
            html.nl();
            html.c(); //table
            html.nl();
        }
Пример #4
0
 public void Write(Report rep, IHtmlReportTheme theme)
 {
     Render(rep, theme, null);
 }
Пример #5
0
 public static String RenderReport(Report rep, IHtmlReportTheme theme)
 {
     return(RenderReport(rep, theme, null));
 }
Пример #6
0
        public void Render(Report rep, IHtmlReportTheme theme, Dictionary<String, HtmlCellStyle> stylesheet)
        {
            report = rep;

            html.e("table").att("cellpadding", 0).att("cellspacing", 0);
            html.nl();
            html.e("tbody");
            html.nl();

            row = -1;
            tro = false;
            col = -1;

            List<HtmlCellStyle> styleCache = new List<HtmlCellStyle>();
            foreach (var v in Enum.GetValues(typeof(CellStyleIndex)))
            {
                styleCache.Add(theme != null ? theme.GetStyle((CellStyleIndex)v) : null);
            }

            merged = new HashSet<int>();
            colSpan = new Dictionary<int, int>();
            rowSpan = new Dictionary<int, int>();

            if (report.MergedCells!=null)
                foreach (var mc in report.MergedCells)
                {
                    for (int c = mc.Col1; c <= mc.Col2; c++)
                        for (int r = mc.Row1; r <= mc.Row2; r++)
                            merged.Add(CellIndex(r, c));
                    int ci = CellIndex(mc.Row1, mc.Col1);
                    merged.Remove(ci);
                    if (mc.Col2 > mc.Col1)
                        colSpan.Add(ci, mc.Col2 - mc.Col1 + 1);
                    if (mc.Row2 > mc.Row1)
                        rowSpan.Add(ci, mc.Row2 - mc.Row1 + 1);
                }
            if (rep.Cells!=null)
                foreach (var cell in report.Cells)
                {
                    if (cell.Row != row)
                    {
                        CompleteRow();
                        StartRow(cell.Row, cell.Column);
                    }
                    ExtendRow(cell.Column);
                    var ind = CellIndex(cell.Row, cell.Column);
                    if (!Merged(ind))
                    {
                        html.td();
                        CheckMergeOrigin(ind);
                        HtmlCellStyle style = null;

                        if (String.IsNullOrEmpty(cell.CellStyleName) || stylesheet == null || !stylesheet.TryGetValue(cell.CellStyleName, out style))
                            style = styleCache[(int)cell.CellStyleIndex];

                        String css = null;
                        String styles = null;
                        if (style != null) {
                            if (style.CssClass!=null)
                                css = style.CssClass;
                            if (style.Style!=null)
                                styles = style.Style;
                        }

                        if (cell.CustomStyle != null)
                            styles += (styles != null ? " " : "") + HtmlCellStyle.BuildHtmlStyle(cell.CustomStyle);

                        html.attCls(css);
                        html.attStyle(styles);

                        switch (cell.Alignment)
                        {
                            case CellAlignment.Left:
                                html.att("align", "left");
                                break;
                            case CellAlignment.Right:
                                html.att("align", "right");
                                break;
                            case CellAlignment.Center:
                                html.att("align", "center");
                                break;
                        }
                        if (String.IsNullOrEmpty(cell.FormattedValue))
                            html.nbsp();
                        else
                            html.text(cell.FormattedValue, HtmlEncode);
                        html.c(); //td
                    }
                }

            CompleteRow();
            html.c(); //tbody
            html.nl();
            html.c(); //table
            html.nl();
        }
Пример #7
0
 public static String RenderReport(Report rep, IHtmlReportTheme theme)
 {
     return RenderReport(rep, theme, null);
 }
Пример #8
0
 public void Write(Report rep, IHtmlReportTheme theme)
 {
     Render(rep, theme, null);
 }