Beispiel #1
0
        private string ExportToCSV()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            //-------------------------------- slice---------------------------------------

            Hierarchy[] hiers = this.Axes[2].Hierarchies.ToSortedByUniqueNameArray();
            for (int i = 0; i < hiers.Length; i++)
            {
                Hierarchy hier = hiers[i];

                //not displaying without mems
                if (hier.FilterMember == null)
                {
                    continue;
                }

                DataMember mem = hier.FilterMember;
                //not displaying only with "All" members
                if (mem.LevelDepth == 0 && !(mem is CalculatedMember) && hier.Levels[0].IsAllLevel)
                {
                    continue;
                }

                // add hier and mem
                sb.Append(hier.DisplayName);
                sb.Append(": ");

                Olap.CalculatedMemberTemplates.MembersAggregate aggMem = mem as Olap.CalculatedMemberTemplates.MembersAggregate;
                if (aggMem != null)              //if aggregate, show children instead of agg itself
                {
                    for (int j = 0; j < aggMem.Members.Count; j++)
                    {
                        sb.Append(aggMem.Members[j].Name);

                        if (j < aggMem.Members.Count - 1)
                        {
                            sb.Append(", ");
                        }
                    }
                }
                else
                {
                    sb.Append(mem.Name);
                }
                sb.Append("\r\n");
            }

            sb.Append("\r\n");
            //-----------------------------------------------------------------------------



            int Ax0MemCount = this.Cellset.Axis0TupleMemCount;
            int Ax1MemCount = this.Cellset.Axis1TupleMemCount;
            int Ax0PosCount = this.Cellset.Axis0PosCount;
            int Ax1PosCount = this.Cellset.Axis1PosCount;

            Hierarchy ax1Hier = null;
            Hierarchy ax0Hier = null;

            //-------------------------------- table---------------------------------------
            System.Web.UI.HtmlControls.HtmlTableRow  tr = null;
            System.Web.UI.HtmlControls.HtmlTableCell td = null;

            if (this.Cellset.IsValid == false)
            {
                return("Cellset contains no data");
            }


            for (int i = 0; i < Ax0MemCount; i++)
            {
                for (int j = 0; j < Ax1MemCount; j++)
                {
                    //hier uname in last row
                    if (i == Ax0MemCount - 1)
                    {
                        sb.Append(this.Axes[1].Hierarchies[j].DisplayName);
                    }

                    sb.Append("\t");
                }

                ax0Hier = this.Axes[0].Hierarchies[i];
                for (int j = 0; j < Ax0PosCount; j++)
                {
                    CellsetMember mem = this.Cellset.GetCellsetMember(0, i, j);
                    sb.Append(mem.Name);
                    sb.Append("\t");
                }


                // hier name in last col
                sb.Append(ax0Hier.DisplayName);

                sb.Append("\r\n");
            }


            for (int i = 0; i < Ax1PosCount; i++)
            {
                for (int j = 0; j < Ax1MemCount; j++)
                {
                    ax1Hier = this.Axes[1].Hierarchies[j];
                    CellsetMember mem = this.Cellset.GetCellsetMember(1, j, i);
                    sb.Append(mem.Name);
                    sb.Append("\t");
                }

                for (int j = 0; j < Ax0PosCount; j++)
                {
                    Cell olapCell = this.Cellset.GetCell(j, i);
                    sb.Append(olapCell.FormattedValue.Replace(System.Globalization.NumberFormatInfo.CurrentInfo.NumberGroupSeparator, ""));
                    sb.Append("\t");
                }

                sb.Append("\r\n");
            }

            return(sb.ToString());
        }
        public void SetHierarchyAggregate(string UniqueName , bool Value)
        {
            Hierarchy hier=_report.Schema.Hierarchies[UniqueName];
            if(hier==null)
                throw new Exception("Error: invalid identifier");

            if(Value==true)
            {
                MembersAggregate aggr=new MembersAggregate(null, hier , MembersAggregate.AggregateFunction.AGGREGATE);
                hier.AddMember(aggr, true);
            }
            else
                hier.AddMember(hier.Levels[0].DefaultMember, true);
        }
Beispiel #3
0
        private string ExportToHTML()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // style
            sb.Append(@"
			<html><head><meta charset='utf-8'></meta>
			<style>
			.tbl1_H {
				text-align:left; PADDING-RIGHT: 2pt; border: solid 1px #aaaaaa; PADDING-LEFT: 2pt; FONT-SIZE: 8pt;  COLOR: black;   font-face: tahoma ; ; padding-top: 1px ; padding-bottom: 1px; BACKGROUND-COLOR: #e0e0e0; 
				}
			.tbl1_H1 {
				text-align:left; PADDING-RIGHT: 2pt; border: solid 1px #aaaaaa; PADDING-LEFT: 2pt; FONT-SIZE: 8pt;  COLOR: black; FONT-WEIGHT: bold;   font-face: tahoma ; ; padding-top: 1px ; padding-bottom: 1px; BACKGROUND-COLOR: #e0e0e0; 
				}

			.tbl1_H2 {
				text-align:center; PADDING-RIGHT: 2pt; border: solid 1px #aaaaaa;  PADDING-LEFT: 2pt; FONT-SIZE: 8pt;  COLOR: black;   font-face: tahoma ; padding-top: 1px ; padding-bottom: 1px; BACKGROUND-COLOR: #e0e0e0; 
				}
			.tbl1_H3 {
				text-align:center; PADDING-RIGHT: 2pt; border: solid 1px #aaaaaa; PADDING-LEFT: 2pt; FONT-SIZE: 8pt;  COLOR: black; FONT-WEIGHT: bold;   font-face: tahoma ; ; padding-top: 1px ; padding-bottom: 1px; BACKGROUND-COLOR: #e0e0e0; 
				}

			.tbl1_HC {
				background-color:#FFFFC0; FONT-SIZE: 8pt; font-face: tahoma;PADDING-LEFT: 2pt;PADDING-RIGHT: 2pt;
				}

			.tbl1_T {
				border-collapse:collapse; 
				}
			.tbl1_C {
				text-align:right; PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 8pt; BACKGROUND-COLOR: white; font-face: tahoma; padding-top: 1px ; padding-bottom: 1px; border: solid 1px #888888;
				}
			.tbl1_C1 {
				text-align:left; PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 8pt; BACKGROUND-COLOR: white; font-face: tahoma; padding-top: 1px ; padding-bottom: 1px; border: solid 1px #888888;
				}
			.tbl1_C2 {
				text-align:right; PADDING-RIGHT: 2pt; PADDING-LEFT: 6pt; FONT-SIZE: 8pt; BACKGROUND-COLOR: white; font-face: tahoma; padding-top: 1px ; padding-bottom: 1px; border: solid 1px #888888;
				}
			</style>
			</head>
			<body>
			"            );


            // ----- HEADER ------
            sb.Append(@"
			<table cellspacing=0 cellpadding=3 width=100% class=capt><tr><td align=right style='BORDER-WIDTH:0px;background-color:red'>
			<font face=ArialBlack color=white size=1><b><i>&copy;&nbsp;FieldForce Solutions &nbsp;</b></i></font>
			</tr></td>
			<tr><td style='BACKGROUND:#e0e0e0; BORDER-WIDTH:0px;'>
			<B><font color=red size=-1>"             + this.Description + @"</font></B><font color=black size=-2><i>&nbsp;(description)</i></font>
			<br>
			<B><font color=4682b4 size=-2>"             + this.Name + @"</font></B><font color=black size=-2><i>&nbsp;(name)</i></font>
			<BR>
			<B><font color=4682b4 size=-2>"             + this.Owner.Name + @"</font></B><font color=black size=-2><i>&nbsp;(owner)</i></font>
			<BR>
			<B><font color=4682b4 size=-2>"             + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString() + @"</font></B><font color=black size=-2><i>&nbsp;(distributed)</i></font>
			</td></tr>
			</table>
			<hr>
			"            );


            //-------------------------------- slice---------------------------------------

            // table start
            sb.Append("<table cellpadding=0 cellspacing=0 width=100 class='tbl1_T'>");

            Hierarchy[] hiers = this.Axes[2].Hierarchies.ToSortedByUniqueNameArray();

            for (int i = 0; i < hiers.Length; i++)
            {
                Hierarchy hier = hiers[i];

                //not displaying without mems
                if (hier.FilterMember == null)
                {
                    continue;
                }

                DataMember mem = hier.FilterMember;
                //not displaying only with "All" members
                if (mem.LevelDepth == 0 && !(mem is CalculatedMember) && hier.Levels[0].IsAllLevel)
                {
                    continue;
                }

                // add hier row
                sb.Append("<tr><td class=tbl1_H nowrap=1>");
                sb.Append(hier.DisplayName);
                sb.Append("</td></tr>");

                // add mem row
                Olap.CalculatedMemberTemplates.MembersAggregate aggMem = mem as Olap.CalculatedMemberTemplates.MembersAggregate;
                if (aggMem != null)              //if aggregate, show children instead of agg itself
                {
                    foreach (Olap.Object childMem in aggMem.Members)
                    {
                        sb.Append("<tr><td class=tbl1_C nowrap=1>");
                        sb.Append(childMem.Name);
                        sb.Append("</td></tr>");
                    }
                    continue;
                }
                sb.Append("<tr><td class=tbl1_C nowrap=1>");
                sb.Append(mem.Name);
                sb.Append("</td></tr>");
            }

            // table end
            sb.Append("</table><br>");

            //-----------------------------------------------------------------------------



            if (this.Cellset.IsValid == false)
            {
                return("Cellset contains no data");
            }

            int Ax0MemCount = this.Cellset.Axis0TupleMemCount;
            int Ax1MemCount = this.Cellset.Axis1TupleMemCount;
            int Ax0PosCount = this.Cellset.Axis0PosCount;
            int Ax1PosCount = this.Cellset.Axis1PosCount;

            int ax0OrderPos = this.GetOrderPosition(this.Axes[0]);
            int ax1OrderPos = this.GetOrderPosition(this.Axes[1]);

            Hierarchy ax1Hier = null;
            Hierarchy ax0Hier = null;

            // table start
            sb.Append("<table cellpadding=0 cellspacing=0 class='tbl1_T'>");


            if (Ax0PosCount == 0 && Ax1PosCount == 0)
            {
                return("Cellset contains no data");
            }


            for (int i = 0; i < Ax0MemCount; i++)
            {
                sb.Append("<tr>");                 //row start

                for (int j = 0; j < Ax1MemCount; j++)
                {
                    sb.Append("<td class='tbl1_HC' nowrap=1>");
                    //hier uname in last row
                    if (i == Ax0MemCount - 1)
                    {
                        sb.Append(this.Axes[1].Hierarchies[j].DisplayName);
                    }
                    sb.Append("</td>");
                }

                ax0Hier = this.Axes[0].Hierarchies[i];
                for (int j = 0; j < Ax0PosCount; j++)
                {
                    bool          inOrderTuple = false;
                    CellsetMember mem          = this.Cellset.GetCellsetMember(0, i, j);

                    //if same as prev, continue
                    if (j != 0 && this.Cellset.GetCellsetMember(0, i, j - 1).UniqueName == mem.UniqueName)
                    {
                        continue;
                    }

                    // handle order position highlight
                    if (j == ax0OrderPos)                  // in order tuple
                    {
                        inOrderTuple = true;
                    }

                    // handle colspan
                    int spanCount = 1;
                    for (int n = j + 1; n < Ax0PosCount; n++)
                    {
                        CellsetMember nextMem = this.Cellset.GetCellsetMember(0, i, n);
                        if (nextMem.UniqueName == mem.UniqueName)
                        {
                            spanCount++;

                            // handle order position highlight
                            if (n == ax0OrderPos)
                            {
                                inOrderTuple = true;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    // handle order position highlight
                    if (inOrderTuple)                    // in order tuple
                    {
                        sb.Append("<td class='tbl1_H3' nowrap=1 ");
                    }
                    else
                    {
                        sb.Append("<td class='tbl1_H2' nowrap=1 ");
                    }

                    // if we span
                    if (spanCount > 1)
                    {
                        sb.Append("colspan=" + spanCount.ToString());
                    }

                    sb.Append(">");
                    sb.Append(mem.Name);
                    sb.Append("</td>");
                }


                // hier in last col
                sb.Append("<td class='tbl1_HC' nowrap=1>");
                sb.Append(ax0Hier.DisplayName);
                sb.Append("</td>");

                sb.Append("</tr>");                 //row end
            }



            for (int i = 0; i < Ax1PosCount; i++)
            {
                sb.Append("<tr>");                 //row start

                for (int j = 0; j < Ax1MemCount; j++)
                {
                    bool inOrderTuple = false;
                    ax1Hier = this.Axes[1].Hierarchies[j];
                    CellsetMember mem = this.Cellset.GetCellsetMember(1, j, i);

                    //if same as prev, continue
                    if (i != 0 && this.Cellset.GetCellsetMember(1, j, i - 1).UniqueName == mem.UniqueName)
                    {
                        continue;
                    }

                    // handle order position highlight
                    if (i == ax1OrderPos)                  // in order tuple
                    {
                        inOrderTuple = true;
                    }


                    // handle rowspan
                    int spanCount = 1;
                    for (int n = i + 1; n < Ax1PosCount; n++)
                    {
                        CellsetMember nextMem = this.Cellset.GetCellsetMember(1, j, n);
                        if (nextMem.UniqueName == mem.UniqueName)
                        {
                            spanCount++;

                            // handle order position highlight
                            if (n == ax1OrderPos)
                            {
                                inOrderTuple = true;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    // handle order position highlight
                    if (inOrderTuple)                    // in order tuple
                    {
                        sb.Append("<td class='tbl1_H1' nowrap=1 ");
                    }
                    else
                    {
                        sb.Append("<td class='tbl1_H' nowrap=1 ");
                    }

                    // if we span
                    if (spanCount > 1)
                    {
                        sb.Append("rowspan=" + spanCount.ToString());
                    }

                    sb.Append(">");
                    sb.Append(mem.Name);
                    sb.Append("</td>");
                }

                for (int j = 0; j < Ax0PosCount; j++)
                {
                    sb.Append("<td class='tbl1_C' nowrap=1>");
                    Cell olapCell = this.Cellset.GetCell(j, i);
                    sb.Append(olapCell.FormattedValue);
                    sb.Append("</td>");
                }

                sb.Append("</tr>");                 // row end
            }

            sb.Append("</table>");             // table end
            sb.Append("</body></html>");       // body end

            return(sb.ToString());
        }