Exemple #1
0
        /// <summary>
        /// Create instance of DateTimeCellType.
        /// </summary>
        /// <param name="dateFormatString">DateTime Format string.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException"><c>dateFormat</c> is out of range.</exception>
        public static DateTimeCellType CreateDateTimeCellType(string dateFormatString)
        {
            DateTimeCellType cellType = new DateTimeCellType();

            cellType.UserDefinedFormat = dateFormatString;
            cellType.DateTimeFormat    = DateTimeFormat.UserDefined;
            cellType.MaximumDate       = new DateTime(DateTime.Today.AddYears(10).Year, DateTime.Today.Month, DateTime.Today.Day);
            cellType.MinimumDate       = new DateTime(DateTime.Today.AddYears(-10).Year, DateTime.Today.Month, DateTime.Today.Day);


            return(cellType);
        }
Exemple #2
0
        /// <summary>
        /// Get format string for Excel's cell.
        /// </summary>
        /// <param name="cellType">Specific CellType</param>
        /// <returns></returns>
        private string GetExcelCellFormatString(ICellType cellType)
        {
            string strFormat = "";

            if (cellType is NumberCellType)
            {
                NumberCellType numberCellType = (NumberCellType)cellType;
                if (numberCellType.DecimalPlaces < 0)
                {
                    strFormat = "#,##0.00";
                }
                else if (numberCellType.DecimalPlaces == 0)
                {
                    if (numberCellType.ShowSeparator)
                    {
                        strFormat = "#,##0";
                    }
                    else
                    {
                        strFormat = "#0";
                    }
                }
                else
                {
                    string decimalPlace = "";
                    decimalPlace = decimalPlace.PadLeft(numberCellType.DecimalPlaces, '0');
                    strFormat    = "#,##0." + decimalPlace;
                }
            }
            else if (cellType is DateTimeCellType)
            {
                DateTimeCellType dateTimeCellType = (DateTimeCellType)cellType;
                if (dateTimeCellType.UserDefinedFormat == String.Empty)
                {
                    strFormat = CommonLib.Common.CurrentUserInfomation.DateFormat.ToString();// CommonLib.Common.CurrentUserInfomation.DateFormat.ToString();
                }
                else
                {
                    strFormat = dateTimeCellType.UserDefinedFormat;
                }
            }
            else
            {
                strFormat = "@";
            }

            return(strFormat);
        }
Exemple #3
0
        public static ICellType CreateInstance(FormatInfo Format)
        {
            ICellType r = null;

            if (Format.Style == FormatStyle.Currency ||
                Format.Style == FormatStyle.General ||
                Format.Style == FormatStyle.Number ||
                Format.Style == FormatStyle.Percent ||
                Format.Style == FormatStyle.ScientificCount)
            {
                FarPoint.Win.Spread.CellType.GeneralCellType rs = new FarPoint.Win.Spread.CellType.GeneralCellType();
                rs.FormatString = Format.Format;
                rs.WordWrap     = true;
                r = rs;
                return(r);
            }
            else if (Format.Style == FormatStyle.Date ||
                     Format.Style == FormatStyle.Time)
            {
                DateTimeCellType ds = new DateTimeCellType();
                ds.UserDefinedFormat = Format.Format;
                r = ds;
                return(r);
            }
            else if (Format.Style == FormatStyle.Text)
            {
                FarPoint.Win.Spread.CellType.TextCellType rs = new FarPoint.Win.Spread.CellType.TextCellType();
                rs.Multiline = true;
                rs.WordWrap  = true;
                r            = rs;
                return(r);
            }
            else
            {
                FarPoint.Win.Spread.CellType.GeneralCellType gs = new FarPoint.Win.Spread.CellType.GeneralCellType();
                gs.FormatString = Format.Format;
                r = gs;
                return(r);
            }
        }
Exemple #4
0
        private void BindStadiumData()
        {
            DataTable Data = DocumentHelperClient.SearchStadiumByWTBH(toolStripTextBox1.Text.Trim());

            if (Data != null)
            {
                spread_stadium.ShowRow(spread_stadium.GetActiveRowViewportIndex(), 0, VerticalPosition.Top);
                spread_stadium_sheet.Rows.Count = Data.Rows.Count;
                if (Data.Rows.Count == 0)
                {
                    return;
                }
                int HiddenColumnCount = 4;
                spread_stadium_sheet.Columns.Count = Data.Columns.Count - HiddenColumnCount;
                if (spread_stadium_sheet.Columns.Count > 0)
                {
                    spread_stadium_sheet.Columns[0].Width  = 90;
                    spread_stadium_sheet.Columns[1].Width  = 120;
                    spread_stadium_sheet.Columns[2].Width  = 140;
                    spread_stadium_sheet.Columns[3].Width  = 120;
                    spread_stadium_sheet.Columns[4].Width  = 110;
                    spread_stadium_sheet.Columns[5].Width  = 80;
                    spread_stadium_sheet.Columns[6].Width  = 90;
                    spread_stadium_sheet.Columns[7].Width  = 80;
                    spread_stadium_sheet.Columns[8].Width  = 120;
                    spread_stadium_sheet.Columns[9].Width  = 120;
                    spread_stadium_sheet.Columns[10].Width = 120;
                    spread_stadium_sheet.Columns[0, spread_stadium_sheet.Columns.Count - 1].VerticalAlignment   = CellVerticalAlignment.Center;
                    spread_stadium_sheet.Columns[0, spread_stadium_sheet.Columns.Count - 1].HorizontalAlignment = CellHorizontalAlignment.Center;
                }

                DateTimeCellType datetime = new DateTimeCellType();
                datetime.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate;
                FarPoint.Win.Spread.CellType.TextCellType text = new FarPoint.Win.Spread.CellType.TextCellType();
                text.Multiline = true;
                text.WordWrap  = true;

                spread_stadium_sheet.Columns[5].CellType = datetime;

                spread_stadium_sheet.Rows.Count = Data.Rows.Count;
                if (Data.Rows.Count > 0)
                {
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].Height = 35;
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].Locked = true;
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].HorizontalAlignment = CellHorizontalAlignment.Center;
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].VerticalAlignment   = CellVerticalAlignment.Center;
                }

                int i, j;
                foreach (System.Data.DataColumn Column in Data.Columns)
                {
                    if (Column.ColumnName == "ID" || Column.ColumnName == "DataID" || Column.ColumnName == "ModuleID" || Column.ColumnName == "DateSpan")
                    {
                        continue;
                    }

                    i = Data.Columns.IndexOf(Column);
                    spread_stadium_sheet.Columns[i - HiddenColumnCount].VerticalAlignment = CellVerticalAlignment.Center;
                    spread_stadium_sheet.Columns[i - HiddenColumnCount].Label             = Column.ColumnName;

                    foreach (DataRow Row in Data.Rows)
                    {
                        j = Data.Rows.IndexOf(Row);
                        spread_stadium_sheet.Rows[j].HorizontalAlignment           = CellHorizontalAlignment.Center;
                        spread_stadium_sheet.Cells[j, i - HiddenColumnCount].Value = Row[Column.ColumnName].ToString();
                    }
                }

                foreach (DataRow Row in Data.Rows)
                {
                    j = Data.Rows.IndexOf(Row);
                    spread_stadium_sheet.Rows[j].Tag = Row["DataID"].ToString() + "," + Row["ModuleID"].ToString() + "," + Row["ID"].ToString();
                }

                spread_stadium.CellDoubleClick -= new CellClickEventHandler(spread_stadium_CellDoubleClick);
                spread_stadium.CellDoubleClick += new CellClickEventHandler(spread_stadium_CellDoubleClick);
            }

            if (Data == null || Data.Rows.Count == 0)
            {
                MessageBox.Show("未找到数据,请检查委托编号是否正确;或重新保存资料!");
            }
        }
Exemple #5
0
        private void LogDialog_Load(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);
            InitLogCategoryInfo();
            Dictionary <Guid, SheetView> SheetCollection = new Dictionary <Guid, SheetView>();

            try
            {
                List <FarPoint.CalcEngine.FunctionInfo> Infos = FunctionItemInfoUtil.getFunctionItemInfos();
                FpSpread.Sheets.Clear();
                if (dataID == Guid.Empty)
                {
                    return;
                }
                JZDocument document        = DocumentHelperClient.GetDocumentByID(dataID);
                JZDocument defaultDocument = ModuleHelperClient.GetDefaultDocument(moduleID);

                List <JZFormulaData> CrossSheetFormulaInfos = ModuleHelperClient.GetFormulaByModuleIndex(moduleID);

                foreach (JZSheet sheet in defaultDocument.Sheets)
                {
                    ProgressScreen.Current.SetStatus = "正在初始化表单‘" + sheet.Name + "’";
                    String    sheetXML  = ModuleHelperClient.GetSheetXMLByID(sheet.ID);
                    SheetView SheetView = Serializer.LoadObjectXml(typeof(SheetView), sheetXML, "SheetView") as SheetView;
                    SheetView.Tag               = sheet.ID;
                    SheetView.SheetName         = sheet.Name;
                    SheetView.Cells[0, 0].Value = "";
                    SheetView.Protect           = true;
                    FpSpread.Sheets.Add(SheetView);

                    SheetCollection.Add(sheet.ID, SheetView);
                    foreach (FarPoint.CalcEngine.FunctionInfo Info in Infos)
                    {
                        SheetView.AddCustomFunction(Info);
                    }
                    foreach (JZCell dataCellDefault in sheet.Cells)
                    {
                        Cell    cell     = SheetView.Cells[dataCellDefault.Name];
                        Object  value    = JZCommonHelper.GetCellValue(document, sheet.ID, dataCellDefault.Name);
                        Boolean hasValue = true;
                        if (value == null || value.ToString() == "")
                        {
                            hasValue = false;
                        }
                        if (cell != null)
                        {
                            cell.Font = defaultFont;
                            if (cell.CellType is DownListCellType)
                            {
                                DownListCellType CellType = cell.CellType as DownListCellType;
                                CellType.DropDownButton = false;
                                CellType.DesignMode     = false;
                                cell.Value = value;
                            }
                            else if (cell.CellType is TextCellType)
                            {
                                TextCellType CellType = cell.CellType as TextCellType;
                                if (CellType.FieldType.Description == FieldType.Text.Description)
                                {
                                    CellType.Multiline = true;
                                    CellType.WordWrap  = true;
                                }
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is LongTextCellType)
                            {
                                LongTextCellType CellType = cell.CellType as LongTextCellType;
                                if (CellType.FieldType.Description == FieldType.LongText.Description)
                                {
                                    CellType.Multiline = true;
                                    CellType.WordWrap  = true;
                                }
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is DateTimeCellType)
                            {
                                DateTimeCellType CellType = cell.CellType as DateTimeCellType;
                                CellType.MinimumDate = new DateTime(1753, 1, 1);
                                CellType.MaximumDate = new DateTime(9999, 12, 31);
                                cell.Value           = value;
                            }
                            else if (cell.CellType is RichTextCellType)
                            {
                                RichTextCellType CellType = cell.CellType as RichTextCellType;
                                CellType.Multiline = false;
                                CellType.WordWrap  = false;
                                CellType.MaxLength = CellType.FieldType.Length;
                                if (hasValue)
                                {
                                    cell.Value = value.ToString().Trim('\r', '\n');;
                                }
                            }
                            else if (cell.CellType is NumberCellType)
                            {
                                NumberCellType CellType = cell.CellType as NumberCellType;
                                CellType.MaximumValue = 999999999.9999;
                                CellType.MinimumValue = -999999999.9999;
                                cell.Value            = value;
                            }
                            else if (cell.CellType is MaskCellType)
                            {
                                MaskCellType CellType = cell.CellType as MaskCellType;
                                CellType.Mask = "00000000000000000000000000000000000";
                                if (CellType.CustomMaskCharacters != null && CellType.CustomMaskCharacters.Length > 0)
                                {
                                    CellType.CustomMaskCharacters[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-()()复检";
                                }
                                cell.Value = value;
                            }
                            else if (cell.CellType is ImageCellType)
                            {
                                if (value != null)
                                {
                                    cell.Value = JZCommonHelper.StringToBitmap(value.ToString());
                                }
                            }
                            else
                            {
                                cell.Value = value;
                            }
                        }
                    }
                }

                ProgressScreen.Current.SetStatus = "正在初始化跨表公式...";

                foreach (JZFormulaData formula in CrossSheetFormulaInfos)
                {
                    SheetView Sheet = SheetCollection[formula.SheetIndex];
                    try
                    {
                        Sheet.Cells[formula.RowIndex, formula.ColumnIndex].Formula = formula.Formula;
                    }
                    catch
                    {
                    }
                }

                FpSpread.LoadFormulas(true);

                ProgressScreen.Current.SetStatus = "正在显示资料...";

                UpdateChart();
                UpdateEquation();
                SetNotes();
                //设置只读模式
                if (ReadOnly)
                {
                    foreach (SheetView sheet in FpSpread.Sheets)
                    {
                        sheet.OperationMode = OperationMode.ReadOnly;
                    }
                }
            }
            catch (TimeoutException ex1)
            {
                MessageBox.Show("网络原因造成数据无法访问,请检查本机网络连接,或稍后再试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show("加载试验模板出错!\r\n原因:" + (ex.InnerException != null ? ex.InnerException.Message : ex.Message), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                try
                {
                    this.RemoveOwnedForm(ProgressScreen.Current);
                    ProgressScreen.Current.CloseSplashScreen();
                    this.Activate();
                }
                catch (Exception ex1) { }
            }
        }
Exemple #6
0
        private void BindStadium()
        {
            DataTable Data = null;

            Data = ModuleHelperClient.GetStadiumList("", "", TestRoomCode, -1);

            if (Data != null)
            {
                spread_stadium.ShowRow(spread_stadium.GetActiveRowViewportIndex(), 0, VerticalPosition.Top);
                spread_stadium_sheet.Rows.Count = Data.Rows.Count;
                if (Data.Rows.Count == 0)
                {
                    return;
                }
                int HiddenColumnCount = 4;
                spread_stadium_sheet.Columns.Count = Data.Columns.Count - HiddenColumnCount;
                if (spread_stadium_sheet.Columns.Count > 0)
                {
                    spread_stadium_sheet.Columns[0].Width  = 60;
                    spread_stadium_sheet.Columns[1].Width  = 80;
                    spread_stadium_sheet.Columns[2].Width  = 100;
                    spread_stadium_sheet.Columns[3].Width  = 120;
                    spread_stadium_sheet.Columns[4].Width  = 60;
                    spread_stadium_sheet.Columns[5].Width  = 70;
                    spread_stadium_sheet.Columns[6].Width  = 90;
                    spread_stadium_sheet.Columns[7].Width  = 60;
                    spread_stadium_sheet.Columns[8].Width  = 120;
                    spread_stadium_sheet.Columns[9].Width  = 120;
                    spread_stadium_sheet.Columns[10].Width = 60;
                    spread_stadium_sheet.Columns[11].Width = 120;
                    spread_stadium_sheet.Columns[12].Width = 120;
                    //spread_stadium_sheet.Columns[0, spread_stadium_sheet.Columns.Count - 1].VerticalAlignment = CellVerticalAlignment.Center;
                    //spread_stadium_sheet.Columns[0, spread_stadium_sheet.Columns.Count - 1].HorizontalAlignment = CellHorizontalAlignment.Center;
                }

                DateTimeCellType datetime = new DateTimeCellType();
                datetime.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate;
                FarPoint.Win.Spread.CellType.TextCellType text = new FarPoint.Win.Spread.CellType.TextCellType();
                text.Multiline = true;
                text.WordWrap  = true;

                spread_stadium_sheet.Columns[5].CellType = datetime;

                spread_stadium_sheet.Rows.Count = Data.Rows.Count;
                if (Data.Rows.Count > 0)
                {
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].Height = 35;
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].Locked = true;
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].HorizontalAlignment = CellHorizontalAlignment.Center;
                    spread_stadium_sheet.Rows[0, spread_stadium_sheet.Rows.Count - 1].VerticalAlignment   = CellVerticalAlignment.Center;
                }

                int i, j;
                foreach (System.Data.DataColumn Column in Data.Columns)
                {
                    if (Column.ColumnName == "ID" || Column.ColumnName == "DataID" || Column.ColumnName == "ModuleID" || Column.ColumnName == "DateSpan")
                    {
                        continue;
                    }

                    i = Data.Columns.IndexOf(Column);
                    spread_stadium_sheet.Columns[i - HiddenColumnCount].VerticalAlignment = CellVerticalAlignment.Center;
                    spread_stadium_sheet.Columns[i - HiddenColumnCount].Label             = Column.ColumnName;

                    foreach (DataRow Row in Data.Rows)
                    {
                        j = Data.Rows.IndexOf(Row);
                        spread_stadium_sheet.Rows[j].HorizontalAlignment = CellHorizontalAlignment.Center;
                        if ((i - HiddenColumnCount) == 10)
                        {
                            spread_stadium_sheet.Cells[j, i - HiddenColumnCount].Value = Row[Column.ColumnName].ToString().TrimEnd('0').TrimEnd('.');
                        }
                        else
                        {
                            spread_stadium_sheet.Cells[j, i - HiddenColumnCount].Value = Row[Column.ColumnName].ToString();
                        }
                    }
                }

                foreach (DataRow Row in Data.Rows)
                {
                    j = Data.Rows.IndexOf(Row);
                    spread_stadium_sheet.Rows[j].Tag = Row["DataID"].ToString() + "," + Row["ModuleID"].ToString();
                }

                spread_stadium.CellDoubleClick -= new CellClickEventHandler(spread_stadium_CellDoubleClick);
                spread_stadium.CellDoubleClick += new CellClickEventHandler(spread_stadium_CellDoubleClick);
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            //获得当前用户所在的试验室编码
            String Project      = context.Scheduler.Context.GetString("project");
            String TestRoomCode = context.Scheduler.Context.GetString("currentLabCode");

            if (!string.IsNullOrEmpty(Project) && !string.IsNullOrEmpty(TestRoomCode))
            {
                DataTable Data = DepositoryLabStadiumList.GetLabStadiumList(TestRoomCode);
                if (Data != null)
                {
                    logger.Info(string.Format("[{0}]获取试验龄期提醒信息成功,共{1}条信息。", Project, Data.Rows.Count));

                    if (Data.Rows.Count > 0)
                    {
                        logger.Info(string.Format("[{0}]正在初始化试验龄期提醒信息...", Project));

                        StadiumReminderDialog Dialog = new StadiumReminderDialog();
                        Dialog.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                        FpSpread  FpSpread      = Dialog.FpSpread;
                        SheetView FpSpread_Info = Dialog.FpSpread_Info;

                        FpSpread.ShowRow(FpSpread.GetActiveRowViewportIndex(), 0, VerticalPosition.Top);

                        int HiddenColumnCount = 4;
                        FpSpread_Info.Columns.Count = Data.Columns.Count - HiddenColumnCount;
                        if (FpSpread_Info.Columns.Count > 0)
                        {
                            FpSpread_Info.Columns[0].Width = 160;
                            FpSpread_Info.Columns[1].Width = 110;
                            FpSpread_Info.Columns[2].Width = 80;
                            FpSpread_Info.Columns[3].Width = 120;
                            FpSpread_Info.Columns[4].Width = 100;
                            FpSpread_Info.Columns[5].Width = 120;
                            FpSpread_Info.Columns[6].Width = 190;
                            FpSpread_Info.Columns[7].Width = 190;

                            FpSpread_Info.Columns[0, FpSpread_Info.Columns.Count - 1].VerticalAlignment   = CellVerticalAlignment.Center;
                            FpSpread_Info.Columns[0, FpSpread_Info.Columns.Count - 1].HorizontalAlignment = CellHorizontalAlignment.Center;
                        }

                        DateTimeCellType datetime = new DateTimeCellType();
                        datetime.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate;
                        FarPoint.Win.Spread.CellType.TextCellType text = new FarPoint.Win.Spread.CellType.TextCellType();
                        text.Multiline = true;
                        text.WordWrap  = true;

                        FpSpread_Info.Columns[2].CellType = datetime;
                        FpSpread_Info.Columns[5].CellType = text;
                        FpSpread_Info.Columns[6].CellType = text;
                        FpSpread_Info.Columns[7].CellType = text;

                        FpSpread_Info.Rows.Count = Data.Rows.Count;
                        if (Data.Rows.Count > 0)
                        {
                            FpSpread_Info.Rows[0, FpSpread_Info.Rows.Count - 1].Height = 35;
                            FpSpread_Info.Rows[0, FpSpread_Info.Rows.Count - 1].Locked = true;
                            FpSpread_Info.Rows[0, FpSpread_Info.Rows.Count - 1].HorizontalAlignment = CellHorizontalAlignment.Center;
                            FpSpread_Info.Rows[0, FpSpread_Info.Rows.Count - 1].VerticalAlignment   = CellVerticalAlignment.Center;
                        }

                        int i, j;
                        foreach (System.Data.DataColumn Column in Data.Columns)
                        {
                            if (Column.ColumnName == "ID" || Column.ColumnName == "ModelCode" || Column.ColumnName == "ModelIndex" || Column.ColumnName == "DateSpan")
                            {
                                continue;
                            }

                            i = Data.Columns.IndexOf(Column);
                            FpSpread_Info.Columns[i - HiddenColumnCount].VerticalAlignment = CellVerticalAlignment.Center;
                            FpSpread_Info.Columns[i - HiddenColumnCount].Label             = Column.ColumnName;

                            foreach (DataRow Row in Data.Rows)
                            {
                                j = Data.Rows.IndexOf(Row);
                                FpSpread_Info.Rows[j].HorizontalAlignment           = CellHorizontalAlignment.Center;
                                FpSpread_Info.Cells[j, i - HiddenColumnCount].Value = Row[Column.ColumnName].ToString();
                            }
                        }

                        foreach (DataRow Row in Data.Rows)
                        {
                            j = Data.Rows.IndexOf(Row);
                            FpSpread_Info.Rows[j].Tag = Row["ModelCode"].ToString() + "," + Row["ModelIndex"].ToString() + "," + Row["ID"].ToString() + "," + Row["DateSpan"].ToString();
                        }

                        logger.Info(string.Format("[{0}]正在显示提醒窗口...", Project));

                        Dialog.ShowDialog();
                    }
                }
                else
                {
                    logger.Info(string.Format("[{0}]获取试验龄期提醒信息失败。", Project));
                }

                logger.Info(string.Format("[{0}]试验龄期提醒完毕,试验室编码:{1}", Project, TestRoomCode));
            }
        }
        private void BindPXBGData()
        {
            DataTable Data = PXJZReportDataList.GetEnPXedReport(ModuleID, txtBGBH.Text.Trim());

            if (Data != null && Data.Rows.Count > 0)
            {
                spread_stadium.ShowRow(spread_stadium.GetActiveRowViewportIndex(), 0, VerticalPosition.Top);
                spread_stadium_Sheet1.Rows.Count = Data.Rows.Count;

                int HiddenColumnCount = 2;
                spread_stadium_Sheet1.Columns.Count = Data.Columns.Count - HiddenColumnCount;
                if (spread_stadium_Sheet1.Columns.Count > 0)
                {
                    spread_stadium_Sheet1.Columns[0].Width = 60;
                    spread_stadium_Sheet1.Columns[1].Width = 100;
                    spread_stadium_Sheet1.Columns[2].Width = 80;
                    spread_stadium_Sheet1.Columns[3].Width = 80;
                    spread_stadium_Sheet1.Columns[4].Width = 60;
                    spread_stadium_Sheet1.Columns[5].Width = 60;
                    spread_stadium_Sheet1.Columns[6].Width = 80;
                    spread_stadium_Sheet1.Columns[7].Width = 80;
                    //spread_stadium_Sheet1.Columns[8].Width = 80;
                    //spread_stadium_Sheet1.Columns[9].Width = 80;
                }

                DateTimeCellType datetime = new DateTimeCellType();
                datetime.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.ShortDate;
                FarPoint.Win.Spread.CellType.TextCellType text = new FarPoint.Win.Spread.CellType.TextCellType();
                text.Multiline = true;
                text.WordWrap  = true;

                spread_stadium_Sheet1.Columns[7].CellType = datetime;
                //spread_stadium_Sheet1.Columns[0].Visible = false;
                //spread_stadium_Sheet1.Columns[1].Visible = false;

                spread_stadium_Sheet1.Rows.Count = Data.Rows.Count;

                int i, j;
                foreach (System.Data.DataColumn Column in Data.Columns)
                {
                    if (Column.ColumnName == "ID" || Column.ColumnName == "ModuleID")
                    {
                        continue;
                    }

                    i = Data.Columns.IndexOf(Column);
                    spread_stadium_Sheet1.Columns[i - HiddenColumnCount].VerticalAlignment = CellVerticalAlignment.Center;
                    spread_stadium_Sheet1.Columns[i - HiddenColumnCount].Label             = Column.ColumnName;

                    foreach (DataRow Row in Data.Rows)
                    {
                        j = Data.Rows.IndexOf(Row);
                        spread_stadium_Sheet1.Rows[j].HorizontalAlignment           = CellHorizontalAlignment.Center;
                        spread_stadium_Sheet1.Cells[j, i - HiddenColumnCount].Value = Row[Column.ColumnName].ToString();
                    }
                }

                foreach (DataRow Row in Data.Rows)
                {
                    j = Data.Rows.IndexOf(Row);
                    spread_stadium_Sheet1.Rows[j].Tag = Row["ID"].ToString() + "," + Row["ModuleID"].ToString();
                }

                spread_stadium.CellDoubleClick -= new CellClickEventHandler(spread_stadium_CellDoubleClick);
                spread_stadium.CellDoubleClick += new CellClickEventHandler(spread_stadium_CellDoubleClick);
            }
            else
            {
                MessageBox.Show("未找到数据,请检查委托/报告编号是否正确;或打开重新保存资料!");
            }
        }
Exemple #9
0
        public void setDateTimeCellType(int iRow, int iCol)
        {
            DateTimeCellType dc = new DateTimeCellType();

            _spread.ActiveSheetView.Cells[iRow, iCol].CellType = dc;
        }
Exemple #10
0
        private void DataDialog_Load(object sender, EventArgs e)
        {
            ProgressScreen.Current.ShowSplashScreen();
            this.AddOwnedForm(ProgressScreen.Current);

            Dictionary <Guid, SheetView> SheetCollection = new Dictionary <Guid, SheetView>();
            JZDocument           document               = DocumentHelperClient.GetDocumentByID(DataID);
            JZDocument           defaultDocument        = ModuleHelperClient.GetDefaultDocument(ModuleID);
            List <JZFormulaData> CrossSheetFormulaInfos = ModuleHelperClient.GetLineFormulaByModuleIndex(ModuleID);

            FpSpread.Sheets.Clear();
            LoadSpread(FpSpread, ModuleID);
            #region 初始化表单
            foreach (JZSheet sheet in defaultDocument.Sheets)
            {
                SheetView SheetView = GetSheet(sheet.ID);
                foreach (JZCell dataCellDefault in sheet.Cells)
                {
                    Cell    cell     = SheetView.Cells[dataCellDefault.Name];
                    Object  value    = JZCommonHelper.GetCellValue(document, sheet.ID, dataCellDefault.Name);
                    Boolean hasValue = true;
                    if (value == null || value.ToString() == "")
                    {
                        hasValue = false;
                    }
                    if (cell != null)
                    {
                        #region 处理单元格
                        cell.Locked = false;
                        cell.Font   = defaultFont;
                        if (cell.CellType is DownListCellType)
                        {
                            DownListCellType CellType = cell.CellType as DownListCellType;
                            CellType.DropDownButton = false;
                            CellType.DesignMode     = false;
                            cell.Value = value;
                        }
                        else if (cell.CellType is TextCellType)
                        {
                            TextCellType CellType = cell.CellType as TextCellType;
                            if (CellType.FieldType.Description == FieldType.Text.Description)
                            {
                                CellType.Multiline = true;
                                CellType.WordWrap  = true;
                            }
                            CellType.MaxLength = CellType.FieldType.Length;
                            if (hasValue)
                            {
                                cell.Value = value.ToString().Trim('\r', '\n');;
                            }
                            else
                            {
                                cell.Value = value;
                            }
                        }
                        else if (cell.CellType is LongTextCellType)
                        {
                            LongTextCellType CellType = cell.CellType as LongTextCellType;
                            if (CellType.FieldType.Description == FieldType.LongText.Description)
                            {
                                CellType.Multiline = true;
                                CellType.WordWrap  = true;
                            }
                            CellType.MaxLength = CellType.FieldType.Length;
                            if (hasValue)
                            {
                                cell.Value = value.ToString().Trim('\r', '\n');;
                            }
                            else
                            {
                                cell.Value = value;
                            }
                        }
                        else if (cell.CellType is DateTimeCellType)
                        {
                            DateTimeCellType CellType = cell.CellType as DateTimeCellType;
                            CellType.MinimumDate = new DateTime(1753, 1, 1);
                            CellType.MaximumDate = new DateTime(9999, 12, 31);
                            cell.Value           = value;
                        }
                        else if (cell.CellType is RichTextCellType)
                        {
                            RichTextCellType CellType = cell.CellType as RichTextCellType;
                            CellType.Multiline = false;
                            CellType.WordWrap  = false;
                            CellType.MaxLength = CellType.FieldType.Length;
                            if (hasValue)
                            {
                                cell.Value = value.ToString().Trim('\r', '\n');
                            }
                            else
                            {
                                cell.Value = value;
                            }
                        }
                        else if (cell.CellType is DeleteLineCellType)
                        {//删除线
                            DeleteLineCellType CellType = cell.CellType as DeleteLineCellType;
                            CellType.Multiline = true;
                            CellType.WordWrap  = true;
                            CellType.MaxLength = CellType.FieldType.Length;
                            cell.CellType      = CellType;
                            object objOld = cell.Text;
                            if (hasValue)
                            {
                                cell.Value = new System.Text.RegularExpressions.Regex("'+").Replace(value.ToString(), "'"); //value.ToString();
                                if (string.IsNullOrEmpty(cell.Text))
                                {
                                    RichTextBox rt = new RichTextBox();
                                    rt.Text    = objOld == null ? "" : objOld.ToString();
                                    rt.Font    = new Font("宋体", 10.5f, FontStyle.Regular);
                                    cell.Value = rt.Rtf;
                                }
                            }
                            else
                            {
                                RichTextBox rt = new RichTextBox();
                                rt.Text    = objOld == null ? "" : objOld.ToString();
                                rt.Font    = new Font("宋体", 10.5f, FontStyle.Regular);
                                cell.Value = rt.Rtf;
                            }
                        }
                        else if (cell.CellType is NumberCellType)
                        {
                            NumberCellType CellType = cell.CellType as NumberCellType;
                            CellType.MaximumValue = 999999999.9999;
                            CellType.MinimumValue = -999999999.9999;
                            cell.Value            = value;
                        }
                        else if (cell.CellType is MaskCellType)
                        {
                            MaskCellType CellType = cell.CellType as MaskCellType;
                            for (int i = CellType.Mask.Length; i < CellType.FieldType.Length; i++)
                            {
                                CellType.Mask += "0";
                            }


                            if (CellType.CustomMaskCharacters != null && CellType.CustomMaskCharacters.Length > 0)
                            {
                                CellType.CustomMaskCharacters[0] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-()ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ()复检";
                            }
                            if (value == null || value.ToString().Trim() == "")
                            {
                                cell.Value = null;
                            }
                            else
                            {
                                cell.Value = value.ToString().Trim();
                            }
                        }
                        else if (cell.CellType is ImageCellType)
                        {
                            if (value != null)
                            {
                                cell.Value = JZCommonHelper.StringToBitmap(value.ToString());
                            }
                            else
                            {
                                cell.Value = null;
                            }
                        }
                        else if (cell.CellType is HyperLinkCellType)
                        {
                            if (value != null)
                            {
                                List <string>     lstLink  = new List <string>();
                                HyperLinkCellType hlnkCell = new HyperLinkCellType();
                                try
                                {
                                    lstLink       = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(value.ToString());
                                    hlnkCell.Text = lstLink[0];
                                    hlnkCell.Link = lstLink[1];
                                }
                                catch
                                {
                                    hlnkCell.Text = value.ToString();
                                    hlnkCell.Link = "";
                                }

                                cell.CellType = hlnkCell;
                                //cell.Value = value;
                            }
                            else
                            {
                                HyperLinkCellType hlnkCell = new HyperLinkCellType();
                                cell.CellType = hlnkCell;
                            }
                        }
                        else
                        {
                            cell.Value = value;
                        }
                        #endregion
                        JZCellProperty p = cell.Tag as JZCellProperty;
                        #region 处理单元格属性
                        if (p != null)
                        {
                            cell.Locked = false;
                        }
                        else
                        {
                            //  logger.Error("未能设置数据区信息:单元格" + dataCellDefault.Name + ",表单:" + sheet.Name);
                        }
                        #endregion
                    }
                }
                #region 线路单元格样式
                DataTable dtCellStyle = ModuleHelperClient.GetCellStyleBySheetID(sheet.ID);
                for (int i = 0; i < dtCellStyle.Rows.Count; i++)
                {
                    if (dtCellStyle.Rows[i]["CellStyle"] != null)
                    {
                        JZCellStyle CurrentCellStyle = Newtonsoft.Json.JsonConvert.DeserializeObject <JZCellStyle>(dtCellStyle.Rows[i]["CellStyle"].ToString());
                        if (CurrentCellStyle != null)
                        {
                            string strCellName = dtCellStyle.Rows[i]["CellName"].ToString();
                            Cell   cell        = SheetView.Cells[strCellName];
                            cell.ForeColor = CurrentCellStyle.ForColor;
                            cell.BackColor = CurrentCellStyle.BackColor;
                            cell.Font      = new Font(CurrentCellStyle.FamilyName, CurrentCellStyle.FontSize, CurrentCellStyle.FontStyle);
                        }
                    }
                }
                #endregion
            }
            #endregion

            UpdateChart();
            UpdateEquation();

            //设置只读模式
            if (ReadOnly)
            {
                foreach (SheetView sheet in FpSpread.Sheets)
                {
                    sheet.OperationMode = OperationMode.ReadOnly;
                }
            }
        }
Exemple #11
0
        public static ICellType CreateCellType(string CellType)
        {
            ICellType Result = null;

            switch (CellType.ToLower())
            {
            case "文本":
                Result = new TextCellType();
                break;

            case "数字":
                Result = new NumberCellType();
                break;

            case "百分号":
                Result = new PercentCellType();
                break;

            case "图片":
                Result = new ImageCellType();
                break;

            case "超链接":
                Result = new HyperLinkCellType();
                break;

            case "货币":
                Result = new CurrencyCellType();
                break;

            case "日期时间":
                Result = new DateTimeCellType();
                break;

            case "复选框":
                Result = new CheckBoxCellType();
                break;

            case "上下标":
                Result = new RichTextCellType();
                break;

            case "条形码":
                Result = new BarCodeCellType();
                break;

            case "下拉框":
                Result = new DownListCellType();
                break;

            case "掩码":
                Result = new MaskCellType();
                break;

            case "删除线":
                Result = new DeleteLineCellType();
                break;

            default:
                Result = new TextCellType();
                break;
            }

            return(Result);
        }