Esempio n. 1
0
        public virtual void SetCommandStatus(HeaderSettingCommandStatus commandStatus)
        {
            if (commandStatus == HeaderSettingCommandStatus.SelectRow || commandStatus == HeaderSettingCommandStatus.SelectColumn || commandStatus == HeaderSettingCommandStatus.Null)
            {
                Enabled = false;
                Checked = false;
            }
            else
            {
                Enabled = true;

                int row         = fpSpreadForHeaderSetting.CellRange.Row;
                int column      = fpSpreadForHeaderSetting.CellRange.Column;
                int rowCount    = fpSpreadForHeaderSetting.CellRange.RowCount;
                int columnCount = fpSpreadForHeaderSetting.CellRange.ColumnCount;
                for (int i = row; i < row + rowCount; i++)
                {
                    for (int j = column; j < column + columnCount; j++)
                    {
                        CellVerticalAlignment verticalAlignment = fpSpreadForHeaderSetting.SheetMain.Cells[i, j].VerticalAlignment;
                        if (VerticalAlignment != verticalAlignment)
                        {
                            goto End;
                        }
                    }
                }
                Checked = true;
                return;

End:
                Checked = false;
            }
        }
Esempio n. 2
0
        private static void InsertCell(
            DocumentBuilder builder,
            string cellContext,
            CellMerge horizontalMerge = CellMerge.None,
            CellMerge verticalMerge   = CellMerge.None,
            LineStyle lineStyle       = LineStyle.Single,
            CellVerticalAlignment cellVerticalAlignment = CellVerticalAlignment.Center,
            ParagraphAlignment alignment = ParagraphAlignment.Center
            )
        {
            builder.InsertCell();
            builder.CellFormat.Borders.LineStyle = lineStyle;
            builder.CellFormat.Borders.Color     = Color.Black;

            //单元格垂直对齐方向
            builder.CellFormat.VerticalAlignment = cellVerticalAlignment;

            //单元格水平对齐方向
            builder.ParagraphFormat.Alignment = alignment;

            builder.CellFormat.HorizontalMerge = horizontalMerge;
            builder.CellFormat.VerticalMerge   = verticalMerge;

            builder.Write(cellContext);
        }
Esempio n. 3
0
 public CellInfo(int rowIndex, string text, Font font, CellHorizontalAlignment hAlignment, CellVerticalAlignment vAlignment, FarPoint.Win.IBorder border)
 {
     this.rowIndex   = rowIndex;
     this.text       = text;
     this.font       = font;
     this.hAlignment = hAlignment;
     this.vAlignment = vAlignment;
     this.border     = border;
 }
Esempio n. 4
0
        public static VerticalAlignment ToVerticalAlignment(this CellVerticalAlignment cellAlignment)
        {
            switch (cellAlignment)
            {
            case CellVerticalAlignment.Top:
                return(VerticalAlignment.Top);

            case CellVerticalAlignment.Center:
                return(VerticalAlignment.Center);

            case CellVerticalAlignment.Bottom:
                return(VerticalAlignment.Bottom);
            }
            return(VerticalAlignment.Center);
        }
Esempio n. 5
0
        public static TextVerticalAlignment VA2TVA(CellVerticalAlignment s)
        {
            switch (s)
            {
            case CellVerticalAlignment.Top:
                return(TextVerticalAlignment.Top);

            case CellVerticalAlignment.Center:
                return(TextVerticalAlignment.Center);

            case CellVerticalAlignment.Bottom:
                return(TextVerticalAlignment.Bottom);
            }
            return(TextVerticalAlignment.Justify);
        }
Esempio n. 6
0
 /// <summary>
 /// 用Cell的信息填充CellInfo。
 /// </summary>
 /// <param name="cell">Cell的信息。</param>
 public void SetCellInfo(Cell cell)
 {
     row        = cell.Row.Index;
     column     = cell.Column.Index;
     rowSpan    = cell.RowSpan;
     columnSpan = cell.ColumnSpan;
     SetColor(cell.ForeColor);
     SetFont(cell.Font);
     cellBorder.SetCellBorder(cell.Border as LineBorder);
     hAligment = cell.HorizontalAlignment;
     vAligment = cell.VerticalAlignment;
     if (cell.Value != null)
     {
         text = cell.Value.ToString();
     }
 }
Esempio n. 7
0
        public static StringAlignment ConvertVAlignmentToStringAlignment(CellVerticalAlignment verticalAlignment)
        {
            int value = 0;

            switch (verticalAlignment)
            {
            case CellVerticalAlignment.Top:
                value = 0;
                break;

            case CellVerticalAlignment.Bottom:
                value = 2;
                break;

            default:
                value = 1;
                break;
            }
            return((StringAlignment)value);
        }
Esempio n. 8
0
        /// <summary>
        /// 初始化单元格对齐方式
        /// </summary>
        /// <param name="alignment"></param>
        /// <returns></returns>
        private CellVerticalAlignment InitalizeCellAlignment(int alignment)
        {
            CellVerticalAlignment cellAlignment = CellVerticalAlignment.Center;

            switch (alignment)
            {
            case 1:
                cellAlignment = CellVerticalAlignment.Top;
                break;

            case 2:
                cellAlignment = CellVerticalAlignment.Center;
                break;

            case 3:
                cellAlignment = CellVerticalAlignment.Bottom;
                break;

            default:
                break;
            }
            return(cellAlignment);
        }
Esempio n. 9
0
        private void ChangeColOrder_Click(object sender, EventArgs e)
        {
            List <string> listColumns = new List <string>();
            Dictionary <string, OrderInfo> dicColumnInfo = new Dictionary <string, OrderInfo>();

            for (int i = 0; i < sheet.ColumnHeader.Columns.Count - 1; i++)
            {
                if (!sheet.Columns[i].Visible)
                {
                    continue;
                }
                string colNameCH = sheet.ColumnHeader.Cells[0, i].Text;
                string colName   = sheet.ColumnHeader.Cells[1, i].Text;
                string keyName   = string.Format("{0}|{1}", colNameCH, colName);
                listColumns.Add(keyName);

                OrderInfo info = new OrderInfo(sheet.Columns[i].Width);
                for (int j = 0; j < sheet.Rows.Count; j++)
                {
                    if (sheet.Rows[j].Tag != null)
                    {
                        continue;
                    }

                    string text = sheet.Cells[j, i].Text;
                    Font   font = sheet.Cells[j, i].Font;
                    CellHorizontalAlignment hAlignment = sheet.Cells[j, i].HorizontalAlignment;
                    CellVerticalAlignment   vAlignment = sheet.Cells[j, i].VerticalAlignment;
                    FarPoint.Win.IBorder    border     = sheet.Cells[j, i].Border;;
                    CellInfo cellInfo = new CellInfo(j, text, font, hAlignment, vAlignment, border);
                    info.Add(cellInfo);
                }
                dicColumnInfo.Add(keyName, info);
            }
            FormAdjustColOrder dlg = new FormAdjustColOrder(listColumns);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                int index = 0;
                for (int i = 0; i < sheet.ColumnHeader.Columns.Count - 1; i++)
                {
                    if (!sheet.Columns[i].Visible)
                    {
                        continue;
                    }
                    string   colName = listColumns[index++];
                    string[] strs    = colName.Split(new char[] { '|' }, 2);
                    sheet.ColumnHeader.Cells[0, i].Text = strs[0];
                    sheet.ColumnHeader.Cells[1, i].Text = strs[1];
                    sheet.Columns[i].Width = dicColumnInfo[colName].ColumnWidth;
                }
                foreach (string colName in listColumns)
                {
                    int colIndex = GetColumnIndexByColName(colName);
                    if (colIndex >= 0)
                    {
                        OrderInfo info = dicColumnInfo[colName];
                        foreach (CellInfo cellInfo in info)
                        {
                            sheet.Cells[cellInfo.RowIndex, colIndex].Text = cellInfo.Text;
                            sheet.Cells[cellInfo.RowIndex, colIndex].Font = cellInfo.Font;
                            sheet.Cells[cellInfo.RowIndex, colIndex].HorizontalAlignment = cellInfo.HAlignment;
                            sheet.Cells[cellInfo.RowIndex, colIndex].VerticalAlignment   = cellInfo.VAlignment;
                            sheet.Cells[cellInfo.RowIndex, colIndex].Border = cellInfo.Border;
                        }
                    }
                }
                btn_save.Enabled = true;
            }
        }