以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多余空白行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=159930) |
|
-- 作者:dang106 -- 发布时间:2021/1/14 11:33:00 -- 多余空白行
|
|
-- 作者:有点蓝 -- 发布时间:2021/1/14 11:37:00 -- execl本身就有空行,加个判断 For n As Integer = 1 To Sheet.Rows.Count -1 if Sheet(n,0).text.trim() > "" 如果第一列有值 Dim r As Row = Tables("Po_Tracking").AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next end if Next |
|
-- 作者:dang106 -- 发布时间:2021/1/14 14:12:00 -- 以下是引用有点蓝在2021/1/14 11:37:00的发言:
execl本身就有空行,加个判断 |
|
-- 作者:dang106 -- 发布时间:2021/1/14 14:15:00 -- 或者,可不可以添加一个删除空白行的按钮?但不知道代码如何写 |
|
-- 作者:有点蓝 -- 发布时间:2021/1/14 14:16:00 -- 贴出完整代码说明 |
|
-- 作者:dang106 -- 发布时间:2021/1/14 14:18:00 -- Dim Book As New XLS.Book ("c:\\po.tracking.xls") Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("Po_Tracking").StopRedraw() \'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致 Dim nms() As String = {"Customer_Country","ship_to_country","Sales_Order_No","Sales_Order_Date","Customer_PO_number","Customer_PO_Date","Customer_code","Customer_Name","Ship_to_code","SO_remarks","Category","大类","Item_code","Item_description","Customer_item_code","Customer_request_date","Sales_price_with_tax","Sales_order_value","Purchase_Order_number","Purchase_Order_date","采购订单审批日期","Vendor_code","Vendor_Name_ZH","Vendor_Name_EN","PI_number","Pur_Order_currency","PO_Remarks","Pur_Order_booked_QTY","PO_discount","PO_price_with_tax","Discount_PO_price","金额","Ex_works_date","Revised_ex_works_date","Acutal_ex_date","Delay_reason","Forwarder","Acutal_FOB_date","Vendor_invoice_number","入库单号","采购发票单据号","销售发票号","Remarks","提单号"} \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 1 To Sheet.Rows.Count -1 Dim r As Row = Tables("Po_Tracking").AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next Next Tables("Po_Tracking").ResumeRedraw()
|
|
-- 作者:有点蓝 -- 发布时间:2021/1/14 14:21:00 -- 这个代码不可能会重复导入,除非您又调用了一次这个代码。每点击一次按钮肯定就导入一次数据,如果不想导入已经存在的数据,查询判断一下:http://www.foxtable.com/webhelp/topics/2334.htm |