Exemplo n.º 1
0
        /// <summary>
        /// 根据数据,给出对应的显示
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="value"></param>
        public static void setCellImg(FarPoint.Win.Spread.Cell cell, int value)
        {
            cell.HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
            cell.VerticalAlignment   = FarPoint.Win.Spread.CellVerticalAlignment.Center;
            FarPoint.Win.Spread.CellType.ImageCellType imageCell = new FarPoint.Win.Spread.CellType.ImageCellType();
            imageCell.Style = FarPoint.Win.RenderStyle.Normal;
            cell.CellType   = imageCell;

            if (value == (int)WarningResult.YELLOW)
            {
                cell.Value = _pngOrange;
            }
            else if (value == (int)WarningResult.RED)
            {
                cell.Value = _pngRed;
            }
            else if (value == (int)WarningResult.GREEN)
            {
                cell.Value = _pngGreen;
            }
            else if (value == (int)WarningResult.NOT_AVAILABLE)
            {
                cell.Value = _pngGreen;
            }
            else
            {
                cell.Value = _pngGreen;
            }
        }
 /// <summary>
 /// 根据CellInfo,绘制Cell。
 /// </summary>
 /// <param name="cellInfoList">CellInfo列表。</param>
 /// <param name="rowOffSet">起始行。</param>
 private void DrawCells(List <CellInfo> cellInfoList, int rowOffSet)
 {
     foreach (CellInfo cellInfo in cellInfoList)
     {
         int        row        = cellInfo.Row + rowOffSet;
         int        column     = cellInfo.Column;
         int        rowSpan    = cellInfo.RowSpan;
         int        columnSpan = cellInfo.ColumnSpan;
         string     text       = cellInfo.Text;
         Font       font       = cellInfo.GetFont();
         Color      color      = cellInfo.GetColor();
         LineBorder border     = cellInfo.CellBorder.GetBorder();
         FarPoint.Win.Spread.CellHorizontalAlignment hAlignment = cellInfo.HAligment;
         FarPoint.Win.Spread.CellVerticalAlignment   vAlignment = cellInfo.VAligment;
         FarPoint.Win.Spread.Cell cell = sheetMain.Cells[row, column];
         cell.RowSpan             = rowSpan;
         cell.ColumnSpan          = columnSpan;
         cell.Value               = text;
         cell.Font                = font;
         cell.ForeColor           = color;
         cell.Border              = border;
         cell.HorizontalAlignment = hAlignment;
         cell.VerticalAlignment   = vAlignment;
     }
 }
Exemplo n.º 3
0
 private void SetHyperLinkCellTypeCellText(FarPoint.Win.Spread.Cell cell, string text)
 {
     hyperLinkCellType      = new FarPoint.Win.Spread.CellType.HyperLinkCellType();
     hyperLinkCellType.Link = " ";
     hyperLinkCellType.Text = text;
     cell.CellType          = hyperLinkCellType.Clone() as FarPoint.Win.Spread.CellType.HyperLinkCellType;
 }
 public void SetGlobalValue(string globalValue)
 {
     FarPoint.Win.Spread.Cell cell = sheetMain.ActiveCell;
     if (cell != null)
     {
         if (cell.Tag as Column == null)
         {
             if (IsEditing)
             {
                 GeneralEditor generalEditor = EditingControl as GeneralEditor;
                 int           start         = generalEditor.SelectionStart;
                 int           length        = generalEditor.SelectionLength;
                 if (generalEditor.Text == null)
                 {
                     generalEditor.Text = " ";
                     generalEditor.Text = string.Empty;
                 }
                 generalEditor.Text = generalEditor.Text.Remove(start, length);
                 generalEditor.Text = generalEditor.Text.Insert(start, globalValue);
                 generalEditor.Select(start + globalValue.Length, 0);
             }
             else
             {
                 cell.Value = cell.Text + globalValue;
             }
             if (Changed != null)
             {
                 Changed(this, null);
             }
         }
     }
 }
Exemplo n.º 5
0
 private string GetOneCellText(FarPoint.Win.Spread.SheetView sheet, string tagStr)
 {
     FarPoint.Win.Spread.Cell cell = sheet.GetCellFromTag(null, tagStr);
     if (cell != null)
     {
         return(cell.Text);
     }
     return(string.Empty);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 设置单个Cell的Text
 /// </summary>
 /// <param name="sheet">SheetView</param>
 /// <param name="tagStr">Cell的tag</param>
 /// <param name="strText">要显示的Text</param>
 private void SetOneCellText(FarPoint.Win.Spread.SheetView sheet, string tagStr, string strText)
 {
     FarPoint.Win.Spread.Cell cell = sheet.GetCellFromTag(null, tagStr);
     if (cell != null)
     {
         FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
         t.Multiline   = true;
         t.WordWrap    = true;
         cell.CellType = t;
         cell.Text    += strText;
     }
 }
Exemplo n.º 7
0
 private System.Xml.XmlElement RowToXml(int rowIndex)
 {
     FarPoint.Win.Spread.Cell cell = fpMain_Sheet1.Cells[rowIndex, 0];
     System.Xml.XmlElement    node = Forms.frmQuickReportEditor.xmlDocument.CreateElement(XmlAttrDic.HeaderObject.ToString());
     node.SetAttribute(XmlAttrDic.tText.ToString(), cell.Text);
     node.SetAttribute(XmlAttrDic.tFont.ToString(), fc.ConvertToInvariantString(cell.Font));
     node.SetAttribute(XmlAttrDic.tColor.ToString(), System.Drawing.ColorTranslator.ToHtml(cell.ForeColor));
     node.SetAttribute(XmlAttrDic.tHAligment.ToString(), cell.HorizontalAlignment.ToString());
     node.SetAttribute(XmlAttrDic.tVAligment.ToString(), cell.VerticalAlignment.ToString());
     node.SetAttribute(XmlAttrDic.tHeight.ToString(), fpMain_Sheet1.Rows[rowIndex].Height.ToString());
     node.SetAttribute(XmlAttrDic.tRowIndex.ToString(), rowIndex.ToString());
     return(node);
 }
Exemplo n.º 8
0
 public void ParseFromXml(XmlNodeList xmlNodeList)
 {
     fpMain_Sheet1.RowCount = xmlNodeList.Count;
     for (int i = 0; i < xmlNodeList.Count; i++)
     {
         int rowIndex = Convert.ToInt32(Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tRowIndex.ToString(), "0"));
         FarPoint.Win.Spread.Cell cell = fpMain_Sheet1.Cells[rowIndex, 0];
         cell.Text                           = Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tText.ToString(), string.Empty);
         cell.Font                           = fc.ConvertFromInvariantString(Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tFont.ToString(), string.Empty)) as Font;
         cell.ForeColor                      = System.Drawing.ColorTranslator.FromHtml(Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tColor.ToString(), string.Empty));
         cell.HorizontalAlignment            = (FarPoint.Win.Spread.CellHorizontalAlignment)Enum.Parse(typeof(FarPoint.Win.Spread.CellHorizontalAlignment), Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tHAligment.ToString(), FarPoint.Win.Spread.CellHorizontalAlignment.General.ToString()));
         cell.VerticalAlignment              = (FarPoint.Win.Spread.CellVerticalAlignment)Enum.Parse(typeof(FarPoint.Win.Spread.CellVerticalAlignment), Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tVAligment.ToString(), FarPoint.Win.Spread.CellVerticalAlignment.General.ToString()));
         fpMain_Sheet1.Rows[rowIndex].Height = Convert.ToInt64(Managers.Functions.GetNodeAttrValue(xmlNodeList[i], XmlAttrDic.tHeight.ToString(), "0"));
     }
 }
        /// <summary>
        /// 过滤Cell。如果cell没有被visibleCellList中的任何一个Cell挡住,则将cell添加进visibleCellList。
        /// </summary>
        /// <param name="visibleCellList">当前显示出来的Cell。</param>
        /// <param name="cell">被过滤的Cell。</param>
        private void FilterCell(List <FarPoint.Win.Spread.Cell> visibleCellList, FarPoint.Win.Spread.Cell cell)
        {
            //将Cell的位置转化为Point。
            Point p = new Point(cell.Column.Index, cell.Row.Index);

            foreach (FarPoint.Win.Spread.Cell c in visibleCellList)
            {
                //将目前已经显示出来的Cell的位置与所占用的面积转化为Rectangle。
                Rectangle r = new Rectangle(c.Column.Index, c.Row.Index, c.ColumnSpan, c.RowSpan);
                //如果Rectangle包含Point,则说明cell已经被挡住了,则return。
                if (r.Contains(p))
                {
                    return;
                }
            }
            //如果可以执行到这里,说明cell没有被visibleCellList中的任何一个Cell挡住,则将cell添加进visibleCellList。
            visibleCellList.Add(cell);
        }
Exemplo n.º 10
0
 /// <summary>
 /// 设置单个Cell的Text
 /// </summary>
 /// <param name="sheet">SheetView</param>
 /// <param name="tagStr">Cell的tag</param>
 /// <param name="strText">要显示的Text</param>
 private void SetOneCellText(FarPoint.Win.Spread.SheetView sheet, string tagStr, string strText)
 {
     FarPoint.Win.Spread.Cell cell = sheet.GetCellFromTag(null, tagStr);
     if (cell != null)
     {
         FarPoint.Win.Spread.CellType.TextCellType t = new FarPoint.Win.Spread.CellType.TextCellType();
         t.Multiline   = true;
         t.WordWrap    = true;
         cell.CellType = t;
         //把字符串转换成数字进行相加,成功后转回字符串
         try
         {
             if (cell.Text == string.Empty || cell.Text == null)
             {
                 cell.Text = "0";
             }
             if (strText == string.Empty || strText == null)
             {
                 strText = "0";
             }
             decimal intText = (Convert.ToDecimal(cell.Text) + Convert.ToDecimal(strText));
             cell.Text = intText.ToString();
         }
         //如果转换失败则把字符串相加
         catch
         {
             if (cell.Text == "0")
             {
                 cell.Text = "";
             }
             if (strText == "0")
             {
                 strText = "";
             }
             cell.Text += strText;
         }
         //相加结果为零,变成空字符串
         if (cell.Text == "0")
         {
             cell.Text = "";
         }
         //      cell.Text += strText;
     }
 }
 /// <summary>
 /// 设置数据窗口Title名称
 /// </summary>
 protected virtual void SetTitle()
 {
     if (this.SvMain != null)
     {
         if (this.HospitalName != string.Empty)
         {
             try
             {
                 // SvMain.Cells["{title}"].Text = HospitalName + SvMain.Cells["{title}"].Text;
                 FarPoint.Win.Spread.Cell c = null;
                 string CellText            = string.Empty;
                 c = SvMain.GetCellFromTag(c, "{hospitalName}");
                 if (c != null)
                 {
                     CellText = c.Note;
                     CellText = CellText.Replace("{hospitalName}", HospitalName);
                     c.Text   = CellText;
                 }
             }
             catch { }
         }
     }
 }
        /// <summary>
        /// 获得当前显示出来的、并且有Border信息、Text信息的Cell。被其他SpanCell挡住的Cell不被获得。
        /// </summary>
        /// <param name="startRow">起始行。</param>
        /// <param name="endRow">结束行。</param>
        /// <returns>当前显示出来的、并且有Border信息、Text信息的Cell。</returns>
        private List <CellInfo> GetVisibleCellInfo(int startRow, int endRow)
        {
            //所有当前显示出来的Cell。
            List <FarPoint.Win.Spread.Cell> visibleCellList = new List <FarPoint.Win.Spread.Cell>();
            List <CellInfo> cellInfoList = new List <CellInfo>();
            //循环。
            int columnCount = sheetMain.ColumnCount;

            for (int rowIndex = startRow; rowIndex <= endRow; rowIndex++)
            {
                for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
                {
                    FarPoint.Win.Spread.Cell cell = sheetMain.Cells[rowIndex, columnIndex];
                    FilterCell(visibleCellList, cell);
                }
            }
            //对显示出来的Cell进行二次过滤,将无需保存信息的Cell排除。
            foreach (FarPoint.Win.Spread.Cell cell in visibleCellList)
            {
                if (cell.RowSpan == 1 && cell.ColumnSpan == 1)
                {
                    //如果Cell没有字符且没有Border,则不记录。
                    if (cell.Value == null && cell.Border == null)
                    {
                        continue;
                    }
                    if (cell.Value != null && cell.Value.ToString() == string.Empty && cell.Border == null)
                    {
                        continue;
                    }
                }
                CellInfo cellInfo = new CellInfo();
                cellInfo.SetCellInfo(cell);
                cellInfoList.Add(cellInfo);
            }
            return(cellInfoList);
        }
Exemplo n.º 13
0
        private void SetHVToolstripButtom(FarPoint.Win.Spread.Cell cell)
        {
            switch (cell.HorizontalAlignment)
            {
            case FarPoint.Win.Spread.CellHorizontalAlignment.General:
            {
                UnCheckHAligment();
                tbHGeneral.Checked = true;
                break;
            }

            case FarPoint.Win.Spread.CellHorizontalAlignment.Center:
            {
                UnCheckHAligment();
                tbHCenter.Checked = true;
                break;
            }

            case FarPoint.Win.Spread.CellHorizontalAlignment.Right:
            {
                UnCheckHAligment();
                tbHRight.Checked = true;
                break;
            }

            case FarPoint.Win.Spread.CellHorizontalAlignment.Left:
            {
                UnCheckHAligment();
                tbHLeft.Checked = true;
                break;
            }
            }
            switch (cell.VerticalAlignment)
            {
            case FarPoint.Win.Spread.CellVerticalAlignment.General:
            {
                UnCheckVAligment();
                tbVGeneral.Checked = true;
                break;
            }

            case FarPoint.Win.Spread.CellVerticalAlignment.Center:
            {
                UnCheckVAligment();
                tbVCenter.Checked = true;
                break;
            }

            case FarPoint.Win.Spread.CellVerticalAlignment.Bottom:
            {
                UnCheckVAligment();
                tbVBottom.Checked = true;
                break;
            }

            case FarPoint.Win.Spread.CellVerticalAlignment.Top:
            {
                UnCheckVAligment();
                tbVTop.Checked = true;
                break;
            }
            }
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="neuObject"></param>
        /// <returns></returns>
        protected override int OnQuery(object sender, object neuObject)
        {
            //int rtnVal = -1;
            Cursor = Cursors.WaitCursor;

            Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在查询数据,请等待....");

            Application.DoEvents();

            #region 清空数据表格
            if (SvMain.RowCount >= this.dataBeginRowIndex + 1)
            {
                SvMain.ClearRange(this.dataBeginRowIndex, dataBeginColumnIndex, SvMain.Rows.Count - this.dataBeginRowIndex + 1, this.dataDisplayColumns.Length, false);
            }
            #endregion
            #region 参数替换
            FarPoint.Win.Spread.Cell c = null;
            for (int j = 0; j < this.useParamCellsCount; j++)
            {
                string CellText = string.Empty;
                c = SvMain.GetCellFromTag(c, "{QueryParams}");
                if (c != null)
                {
                    CellText = c.Note;
                    for (int i = 0; i < this.QueryParams.Count; i++)
                    {
                        CellText = CellText.Replace("{" + i + "}", this.QueryParams[i].ToString());
                    }
                    c.Text = CellText;
                }
            }
            #endregion
            #region 显示到表格
            DataTable dt = new DataTable();
            dataRowCount = 0;
            switch (this.QuerySqlTypeValue)
            {
            case QuerySqlType.id:
                if (Db.QueryDataBySqlId(this.QuerySql, ref dt, this.QueryParams) != 1)
                {
                    Cursor = Cursors.Arrow;
                    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                    return(-1);
                }
                break;

            case QuerySqlType.text:
                if (Db.QueryDataBySql(this.QuerySql, ref dt, this.QueryParams) != 1)
                {
                    Cursor = Cursors.Arrow;
                    Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();
                    return(-1);
                }
                break;

            default:
                break;
            }
            #region 清空排序状态
            if (this.dataBeginColumnIndex > 0 || this.dataBeginRowIndex > 0)
            {
                //遍历标题列取原排序条件
                for (int i = dataBeginColumnIndex; i < this.dataDisplayColumns.Length; i++)
                {
                    //没有“↑”号就是升序
                    if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("△") >= 0)
                    {
                        //
                        SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("△", "");
                    }
                    //没有“↑”号就是升序
                    if (SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.IndexOf("▽") >= 0)
                    {
                        //
                        SvMain.Cells[this.dataBeginRowIndex - 1, i].Text = SvMain.Cells[this.dataBeginRowIndex - 1, i].Text.Replace("▽", "");
                    }
                }
            }
            #endregion
            DataSetHelper dsh      = new DataSetHelper();
            DataTable     dtValues = dsh.SelectIntoByIndex(string.Empty, dt, dataDisplayColumns, string.Empty, string.Empty);
            this.dataRowCount = dtValues.Rows.Count;
            #region 设置表格列数
            //this.SvMain.ColumnCount = dataDisplayColumns.Length ;
            if (this.SvMain.Rows.Count < DataBeginRowIndex + dt.Rows.Count)
            {
                this.SvMain.RowCount = DataBeginRowIndex + dt.Rows.Count;
            }

            #endregion
            #region 逐个单元格填充数据
            Function.DisplayToFp(SvMain, dtValues, DataBeginRowIndex, DataBeginColumnIndex);
            //foreach (DataRow dr in dt.Rows)
            //{
            //    foreach (DataColumn dc in dt.Columns)
            //    {
            //        if (Array.IndexOf(dataDisplayColumns,dt.Columns.IndexOf(dc).ToString())>=0)
            //        {
            //            SvMain.Cells[dt.Rows.IndexOf(dr) + 1 + DataBeginRowIndex, Array.IndexOf(dataDisplayColumns, dt.Columns.IndexOf(dc).ToString())].Text = dr[dt.Columns.IndexOf(dc)].ToString();
            //        }

            //    }
            //}
            #endregion

            #endregion

            #region 设置分页符
            if (this.rowPageBreak > 0)
            {
                for (int i = 0; i < this.SvMain.Rows.Count; i = ((i + 1) * this.rowPageBreak + this.DataBeginRowIndex))
                {
                    this.SvMain.SetRowPageBreak((i * this.rowPageBreak + this.DataBeginRowIndex), true);
                }
            }
            #endregion

            Function.DrawGridLine(SvMain, this.dataBeginRowIndex, this.dataBeginColumnIndex, dtValues.Rows.Count, dtValues.Columns.Count);
            Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();

            Cursor = Cursors.Arrow;

            return(1);
        }
        /// <summary>
        /// 绘制报表列。
        /// </summary>
        private void DrawReportColumnList()
        {
            int reportColumnRowIndex = ReportColumnRowIndex;

            if (reportColumnRowIndex < 0)
            {
                return;
            }
            LineBorder border1 = new LineBorder(Color.Black, 1, true, true, true, true);
            LineBorder border2 = new LineBorder(Color.Black, 1, false, true, true, true);

            #region 先清空报表列所在行。
            for (int i = 0; i < sheetMain.Columns.Count; i++)
            {
                FarPoint.Win.Spread.Cell cell = sheetMain.Cells[reportColumnRowIndex, i];
                cell.Value  = null;
                cell.Tag    = null;
                cell.Border = null;
                cell.Locked = true;
            }
            #endregion
            if (canEditColumn)
            {
                List <Column> columnList = sheetMain.Rows[reportColumnRowIndex].Tag as List <Column>;
                if (columnList.Count > sheetMain.Columns.Count)
                {
                    sheetMain.Columns.Count = columnList.Count;
                    FpChanged(HeaderSettingFpSpreadChangedType.ColumnCountChanged);
                }
                foreach (Column column in columnList)
                {
                    int i = column.SortID;
                    FarPoint.Win.Spread.Cell cell = sheetMain.Cells[reportColumnRowIndex, i];
                    if (i == 0)
                    {
                        cell.Border = border1;
                    }
                    else
                    {
                        cell.Border = border2;
                    }
                    cell.Value               = column.Name;
                    cell.Tag                 = column;
                    cell.CellType            = normalTextCellType;
                    cell.Font                = column.GetHeaderFont();
                    cell.ForeColor           = column.GetHeaderColor();
                    cell.HorizontalAlignment = column.HeaderHAligment;
                    cell.VerticalAlignment   = column.HeaderVAligment;
                    cell.Locked              = false;
                }
            }
            else
            {
                for (int i = 0; i < sheetMain.Columns.Count; i++)
                {
                    if (i == 0)
                    {
                        sheetMain.Cells[reportColumnRowIndex, i].Border = border1;
                    }
                    else
                    {
                        sheetMain.Cells[reportColumnRowIndex, i].Border = border2;
                    }
                    sheetMain.Cells[reportColumnRowIndex, i].CellType = normalTextCellType;
                }
            }
        }