function tMainForm.CreateUserField():boolean;
var
ldataset:TBizDataSet;
lBizField: TBizField;
lColumn: TDataGridColumn;
Fldid,flddisplayname,smonth,sweek,temp:string;
year,month,days,i,col:integer;
sdate:TDate;
begin
col:=11;
ldataset:=TBizDataSet.Create(self);
ldataSet:=InfoBrokerINFO_BASICDATA.Info.DataSetByID('UserCheckStatTable');
i:=3;
SysUtils.DateTimeToString(temp,'yyyy-MM',dtMonth.date) ;
temp:=temp+'-01';
sdate:=strtodate(temp);
year:=StrToInt(FormatDateTime('yyyy',dtMonth.Date)) ;
month:=StrToInt(FormatDateTime('mm',dtMonth.Date)) ;
days:=DateUtils.DaysInAMonth(year,month);
while i<days do
begin
Fldid:=datetostr(sdate);
case DateUtils.DayOfTheWeek(sdate) of //转为星期
1:sweek:='一';
2:sweek:='二';
3:sweek:='三';
4:sweek:='四';
5:sweek:='五';
6:sweek:='六';
7:sweek:='日' ;
end;
flddisplayname:=inttostr(i)+'|'+sweek;
lBizField := TUserDataField.Create(ldataset);
lBizField.DataSet:=TBizDataSet(ldataset);
lBizField.ID:=Fldid;
lBizField.DataType:=TDataType.dtString;
lBizField.Size:=10;
lBizField.DisplayName:=flddisplayname;
lBizField.Description:='1';
TsheetDoc(DocViewINFO_BASICDATA_FZ_CHECKINOUTSTAT_DOC.Doc).Sheet.CellTypes[4,col]:=TCellType.ctFieldLabel;
TFieldCell(TsheetDoc(DocViewINFO_BASICDATA_FZ_CHECKINOUTSTAT_DOC.Doc).Cells[4,col]).FieldName:=Fldid;
col:=col+1;
i:=i+1;
sdate:=DateUtils.IncDay(sdate,1);
end;
DocViewINFO_BASICDATA_FZ_CHECKINOUTSTAT_DOC.Doc.Close;
DocViewINFO_BASICDATA_FZ_CHECKINOUTSTAT_DOC.OpenView(TDocMode.dmEdit);
end;
[问题]我要在表格内实现动态列添加 下面的代码实现不了 不知道问题出在哪里 |