while not ADataSet.Eof do
begin
with ssbSample.ActiveSheet.GetCellObject(
ADataSet.FieldByName('列').AsInteger,
ADataSet.FieldByName('行').AsInteger) do
begin
Text := '赋值';
end;
ADataSet.Next;
end;
with fmddcldata.ls_table do
for i:=2 to grid.RowCount do begin
Insert;
fields[1].AsString:=local_userid;
if flag='T' then
for j:=2 to grid.ColCount-1 do begin
if trim(grid.Cells[2,i])='' then begin
cancel;
exit;
end;
fields[j].AsString:=trim(grid.Cells[j,i]);
end;
if flag='F' then begin
if trim(grid.Cells[2,i])='' then begin
cancel;
exit;
end;
fields[2].AsString:=trim(grid.Cells[2,i]);
fields[3].AsString:=trim(grid.Cells[3,i]);
fields[4].AsString:=trim(grid.Cells[4,i]);
fields[5].AsString:=trim(grid.Cells[5,i]);
fields[6].AsString:=trim(grid.Cells[6,i]);
fields[7].AsString:='';
for j:=7 to grid.ColCount-1 do begin
fields[j+1].AsString:=trim(grid.Cells[j,i]);
end;
end;
post;
end;
stat2.Panels[2].Text:='记录数:'+inttostr(fmddcldata.ls_table.RecordCount);
application.MessageBox('恭喜您!数据处理完毕!','提示',0);
end;
procedure Tfmddcl.ll_xddClick(Sender: TObject);
var
i, j, k: Integer;
sheet: TSpreadSheet;
Value: Variant;
begin
if not xdd_dialog.Execute then exit;
ll_yddd.Text:=xdd_dialog.FileName;
for i := PageControl2.PageCount-1 downto 0 do
PageControl2.Pages[i].Free;
with TMSExcel.Create(Self) do
try
LoadFromFile(ll_yddd.Text);
for k := 0 to Sheets.Count-1 do
begin
sheet := Sheets.SpreadSheet(k);
if Assigned(sheet) then
begin
{create a tab and grid for each sheet in workbook}
tab := TTabSheet.Create(PageControl2);
tab.Caption := sheet.Caption;
tab.PageControl := PageControl2;
for i := 1 to sheet.Cells.UsedRowCount+1 do
begin
for j := 1 to sheet.Cells.UsedColCount+1 do
begin
Value := sheet.Cells.GetValue(j-1, i-1);
{ if j= 4 then
begin
begin
grid.Cells[j, i]:=FormatDateTime('yyyy-mm-dd', StrToDate(Value));
end
end;
}
if (VarType(Value) = varBoolean) then
begin
if Value then
grid.Cells[j, i] := 'True'
else
grid.Cells[j, i] := 'False'
end
// else if TryStrToDate(Value,'yyyy-mm-dd') then
// grid.Cells[j, i] :=DateToStr(try TryStrToDate(Value,'yyyy-mm-dd'))
else
grid.Cells[j, i] := VarToStr(Value);
end;
end;
for i := 1 to grid.RowCount-1 do
grid.Cells[0, i] := IntToStr(i);
for j := 1 to grid.ColCount-1 do
grid.Cells[j, 0] := Chr(Ord('A') + j - 1);
end;
end;
finally
Free
end;
end;