你看这样的自定义 TextCellType 类型是否满足你的需要,取出来的值没有 00:00:00,但是值的格式为XXXX/XX/XX,而不是XXXX-XX-XX:
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- fpSpread1.ActiveSheet.Columns[0].CellType = new MyDateCellType();
- fpSpread1.ActiveSheet.Cells[0, 0].Value = "2012/01/01";
- }
- }
- public class MyDateCellType : FarPoint.Win.Spread.CellType.TextCellType
- {
- public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
- {
- if (value != null)
- {
- DateTime dt;
- if (DateTime.TryParse(value.ToString(),out dt))
- {
- value = dt.ToString("yyyy-MM-dd");
- }
- }
- base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
- }
- }
复制代码 |