示例#1
0
        /// <summary>
        /// 保存报表配置
        /// </summary>
        private void SaveReportData()
        {
            //report.Configuration.SheetStyle = reportDesignForm.ReportDesignPanel.GetActiveSheetXml();
            //DepositoryReportConfiguration.Update(report.Configuration);
            JZReport r = new JZReport()
            {
                ColumnCount      = 26,
                RepeatRowCount   = 4,
                StartRowIndex    = 7,
                StartColumnIndex = 0
            };
            String json = Newtonsoft.Json.JsonConvert.SerializeObject(r);

            ReportService.SaveReport(new Guid(reportID),
                                     reportDesignForm.ReportDesignPanel.GetActiveSheetXml(), json);
        }
示例#2
0
        public String GetReportString(Guid reportID, String start, String end, String testRoomCodes, Hashtable list)
        {
            String    result = "";
            String    sql    = "SELECT SheetStyle,Config FROM sys_report WHERE ID='" + reportID + "'";
            DataTable dt     = GetDataTable(sql);

            if (dt == null || dt.Rows.Count == 0)
            {
                return("");
            }
            String    xml       = dt.Rows[0][0].ToString();
            SheetView sheetView = (SheetView)Serializer.LoadObjectXml(typeof(SheetView), xml, "SheetView");
            JZReport  report    = Newtonsoft.Json.JsonConvert.DeserializeObject <JZReport>(dt.Rows[0][1].ToString());

            if (sheetView != null && report != null)
            {
                testRoomCodes = testRoomCodes.Replace("'", "");
                sql           = "EXEC dbo.sp_report @sDate = '" + start + "',@eDate = '" + end + "',@testRoomCode = '" + testRoomCodes + "'";
                dt            = GetDataTable(sql);
                //logger.Error(sql);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sheetView.CopyRange(report.StartRowIndex + i, report.StartColumnIndex, report.StartRowIndex + 1 + i,
                                        report.StartColumnIndex, report.RepeatRowCount, report.ColumnCount, false);
                }

                for (int i = 0; i < sheetView.Rows.Count; i++)
                {
                    for (int j = 0; j < report.ColumnCount; j++)
                    {
                        Cell cell = sheetView.Cells[i, j];
                        if (cell.Value == null || cell.Value.ToString().Trim() == "")
                        {
                            continue;
                        }
                        else
                        {
                            if (cell.Value.ToString().StartsWith("@"))
                            {
                                cell.Value = list[cell.Value];
                            }
                            else
                            {
                                if (report.StartRowIndex <= i)
                                {
                                    int index = i - report.StartRowIndex;
                                    if (index >= 0 && index < dt.Rows.Count)
                                    {
                                        if (dt.Columns.Contains(cell.Value.ToString()))
                                        {
                                            cell.Value = dt.Rows[index][cell.Value.ToString()].ToString();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                sheetView.RemoveRows(report.StartRowIndex + dt.Rows.Count, 1);
                result = Serializer.GetObjectXml(sheetView, "SheetView");
            }
            return(result);
        }