论坛中有许多用户询问,Spread 能否实现上下标格式。例如:X3
Spread Winform 实现方法:
RichTextBox rtb = new RichTextBox(); rtb.Text = "e=mc2"; rtb.SelectionStart = 4; rtb.SelectionLength = 1; rtb.SelectionCharOffset = Font.Height / 2; rtb.SelectedText = "2"; fpSpread1.ActiveSheet.Cells[0, 0].Renderer = new FarPoint.Win.Spread.CellType.RichTextCellType(); fpSpread1.ActiveSheet.Cells[0, 0].Value = rtb.Rtf;
效果图:
Spread ASP.NET 实现方法:
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } FpSpread1.EncodeValue = false; FpSpread1.ActiveSheetView.Cells[0, 0].Text = "H<sub>2</sub>0 - Water"; FpSpread1.ActiveSheetView.Cells[1, 0].Text = "H<sup>2</sup>0 - Water"; }
效果图: