dephi TdxSpreadSheet 电子表格组件的运用
//无论是读取值,还是写入值,都要首先判断单元格是否为空,如果为空的话,读写都会出问题.//读取值
procedure TForm1.dxBarButton1Click(Sender: TObject);
var
Cell: TdxSpreadSheetCell;
begin
Cell := dxSpreadSheet1.ActiveSheetAsTable.Cells[0, 1];
if Cell <> nil then
ShowMessage(Cell.AsString)
else
ShowMessage('B2无内容');
end;
// 写入值
procedure TForm1.dxBarButton2Click(Sender: TObject);
var
newCell: TdxSpreadSheetCell;
begin
newCell := dxSpreadSheet1.ActiveSheetAsTable.Cells[1, 1];
if newCell = nil then
newCell := dxSpreadSheet1.ActiveSheetAsTable.CreateCell(1, 1);
newCell.AsString := '又是新的一天';
end;
procedure TForm1.dxBarButton1Click(Sender: TObject);
var
Cell: TdxSpreadSheetCell;
begin
Cell := dxSpreadSheet1.ActiveSheetAsTable.Cells[0, 1];
if Cell <> nil then
ShowMessage(Cell.AsString)
else
ShowMessage('B2无内容');
end;
// 写入值
procedure TForm1.dxBarButton2Click(Sender: TObject);
var
newCell: TdxSpreadSheetCell;
begin
newCell := dxSpreadSheet1.ActiveSheetAsTable.Cells[1, 1];
if newCell = nil then
newCell := dxSpreadSheet1.ActiveSheetAsTable.CreateCell(1, 1);
newCell.AsString := '又是新的一天';
end;