怎么在后台数据库数据类型是数值型的数据在前台显示成文本型的数据,我使用了下面代码但是显示还是数字
fp.Sheets[k].Cells[7, 2].Value = 2;
fp.Sheets[k].Cells[7, 3].Value = 3;
fp.Sheets[k].Cells[7, 4].Value = 4;
fp.Sheets[k].Cells[7, 5].Value = 5;
fp.Sheets[k].Cells[7, 6].Value = 6;
fp.Sheets[k].Cells[7, 7].Value = 7;
fp.Sheets[k].Cells[7, 8].Value = 8;
MycellType my = new MycellType();
//my.Multiline = true;
Dictionary<double, string> items = new Dictionary<double, string>();
items.Add(2, "AA");
items.Add(3, "BB");
items.Add(4, "CC");
items.Add(5, "DD");
items.Add(6, "EE");
my.items = items;
fp.Sheets[k].Cells[7, 2, 7, 6].CellType = my;
my处理:
public class MycellType:FarPoint.Web.Spread.GeneralCellType
{
public MycellType()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
// //public static Dictionary<
public Dictionary<double, string > items
{
get;
set;
}
public override void PaintCell(FarPoint.PDF.PdfGraphics g, System.Drawing.RectangleF r, FarPoint.Web.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
{
if (value != null)
{
double dou = 0.00;
if (double.TryParse(value.ToString(), out dou))
{
//if (value.ToString() != "0.00" && value.ToString() != "0")
//{
value = items[Convert.ToDouble(value.ToString())];
//}
//else
//{
// value = DBNull.Value;
//}
}
else
{
value = value.ToString();
}
}
base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
}
} |
|