回复 12楼sam的帖子
sam 你好
从Spread产品本身的功能来讲,以下代码会将行高变高:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- FarPoint.Web.Spread.Extender.DateCalendarCellType dcct = new FarPoint.Web.Spread.Extender.DateCalendarCellType();
- FpSpread1.ActiveSheetView.Columns[1].CellType = dcct;
- FpSpread1.ActiveSheetView.Columns[1].Width = 0;
- FpSpread1.ActiveSheetView.Cells[0, 1].Value = DateTime.Now.Date;
- }
- }
复制代码
而下面的代码可让行高保存不变:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- GeneralCellType gctD = new GeneralCellType();
- gctD.AllowWrap = false;
- FpSpread1.ActiveSheetView.Columns[1].CellType = gctD;
- FarPoint.Web.Spread.Extender.DateCalendarCellType dcct = new FarPoint.Web.Spread.Extender.DateCalendarCellType();
- FpSpread1.ActiveSheetView.Columns[1].CellType = dcct;
- FpSpread1.ActiveSheetView.Columns[1].Width = 0;
- FpSpread1.ActiveSheetView.Cells[0, 1].Value = DateTime.Now.Date;
- }
- }
复制代码
现在有一个让我不太理解的是,需要将设置为 DateCalendarCellType的列进行隐藏,行高不会自动变高,而且需要显示完整的日期。 既然需要隐藏这一列为什么还要显示日期呢,我理解这个需求是否有点矛盾。
单从功能实现方法来讲,你可以尝试使用自定义的DateCalendarCellType类型:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- CDateCalendarCellType dcct = new CDateCalendarCellType();
- FpSpread1.ActiveSheetView.Columns[1].CellType = dcct;
- FpSpread1.ActiveSheetView.Columns[1].Width = 0;
- FpSpread1.ActiveSheetView.Cells[0, 1].Value = DateTime.Now.Date;
- }
- }
- public class CDateCalendarCellType : FarPoint.Web.Spread.Extender.DateCalendarCellType
- {
- public override Control PaintCell(string id, TableCell parent, Appearance style, Inset margin, object value, bool upperLevel)
- {
- style.Font.Size = 5;
- return base.PaintCell(id, parent, style, margin, value, upperLevel);
- }
- }
复制代码 |