private void Initialize(CellHorizontalAlignment horAlign, CellTextTrimmingStyle textTrimmingStyle, CellNullStyle nullStyle, bool removeTerminalFormats) { HorizontalAlignment = horAlign; TextTrimmingStyle = textTrimmingStyle; NullStyle = nullStyle; _removeTerminalFormats = removeTerminalFormats; }
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++) { CellHorizontalAlignment horizontalAlignment = fpSpreadForHeaderSetting.SheetMain.Cells[i, j].HorizontalAlignment; if (HorizontalAlignment != horizontalAlignment) { goto End; } } } Checked = true; return; End: Checked = false; } }
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; }
/// <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(); } }
public static TextHorizontalAlignment HA2THA(CellHorizontalAlignment s) { switch (s) { case CellHorizontalAlignment.Left: return(TextHorizontalAlignment.Left); case CellHorizontalAlignment.Center: return(TextHorizontalAlignment.Center); case CellHorizontalAlignment.Right: return(TextHorizontalAlignment.Right); case CellHorizontalAlignment.General: return(TextHorizontalAlignment.General); } return(TextHorizontalAlignment.General); }
public static StringAlignment ConvertHAlignmentToStringAlignment(CellHorizontalAlignment horizontalAligment) { int value = 0; switch (horizontalAligment) { case CellHorizontalAlignment.Left: value = 0; break; case CellHorizontalAlignment.Right: value = 2; break; default: value = 1; break; } return((StringAlignment)value); }
/// <summary> /// Initialize a new instance of CellStyle class /// </summary> /// <param name="horizontalAlignment">The cell horizontal alignment</param> /// <param name="textTrimmingStyle">The cell text trimming style</param> /// <param name="nullStyle">The cell null style</param> /// <param name="removeTerminalFormats">True: terminal formats will be removed</param> public CellStyle(CellHorizontalAlignment horizontalAlignment, CellTextTrimmingStyle textTrimmingStyle, CellNullStyle nullStyle, bool removeTerminalFormats) { Initialize(horizontalAlignment, textTrimmingStyle, nullStyle, removeTerminalFormats); }
/// <summary> /// Initialize a new instance of CellStyle class /// </summary> /// <param name="horizontalAlignment">The cell horizontal alignment</param> /// <param name="textTrimmingStyle">The cell text trimming style</param> /// <param name="nullStyle">The cell null style</param> public CellStyle(CellHorizontalAlignment horizontalAlignment, CellTextTrimmingStyle textTrimmingStyle, CellNullStyle nullStyle) { Initialize(horizontalAlignment, textTrimmingStyle, nullStyle, DEFAULT_HANDLE_TERMINAL_FORMATS); }
/// <summary> /// Initialize a new instance of CellStyle class /// </summary> /// <param name="horizontalAlignment">The cell horizontal alignment</param> public CellStyle(CellHorizontalAlignment horizontalAlignment) { Initialize(horizontalAlignment, DEFAULT_ABBREVIATION_STYLE, DEFAULT_NULL_STYLE, DEFAULT_HANDLE_TERMINAL_FORMATS); }
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; } }