zoukankan      html  css  js  c++  java
  • nativeexcel将excel导入数据集

    nativeexcel将excel导入数据集

    uses nexcel;

    procedure Tfgoods.daoruExecute(Sender: TObject);
    var
    od: TOpenDialog;
    wb: IXLSWorkbook;
    ws: IXLSWorksheet;
    irow: integer;
    v: Variant;
    begin
    od := TOpenDialog.Create(nil);
    od.Filter := 'xls|*.xls';
    wb := TXLSWorkbook.Create;
    if od.Execute then
    begin
    wb.Open(od.FileName);
    ws := wb.WorkSheets[1];
    if ws.UsedRange.Rows.Count = 0 then
    Exit;
    // 商品名称 条码 进价 售价 单位
    for irow := 2 to ws.UsedRange.Rows[1].Count - 2 do // 遍历行
    begin
    ADOQuery1.Append; // 追加
    ADOQuery1.FieldByName('goodsid').Text := GetGoodsId;
    v := ws.UsedRange.Cells[irow, 1].Value;
    if not VarIsNull(v) then
    ADOQuery1.FieldByName('goodsname').Text := v;
    v := ws.UsedRange.Cells[irow, 2].Value;
    if not VarIsNull(v) then
    ADOQuery1.FieldByName('barcode').Text := v;
    v := ws.UsedRange.Cells[irow, 3].Value;
    if not VarIsNull(v) then
    ADOQuery1.FieldByName('jingjia').Text := v;
    v := ws.UsedRange.Cells[irow, 4].Value;
    if not VarIsNull(v) then
    ADOQuery1.FieldByName('shoujia').Text := v;
    v := ws.UsedRange.Cells[irow, 5].Value;
    if not VarIsNull(v) then
    ADOQuery1.FieldByName('unitname').Text := v;
    ADOQuery1.Post;
    end;
    end;
    wb.Close;
    od.Free;
    end;

  • 相关阅读:
    mac 命令大全
    GAME OF THRONES 2
    GAME OF THRONES 1
    软件工程-作业一
    猜数字游戏
    摘自-角田光代《对岸的她》
    java复习总结
    艾米莉-狄金森
    初次接触软件工程
    Environment/reflection mapping & bump mapping
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/7905244.html
Copyright © 2011-2022 走看看