使用C#和JScript汇总表
我在C#中编写了代码来汇总InvoiceTable
值,并将这些汇总值移到Abbyy FlexiCapture中的GroupTable。 该软件相对较新,在运行时不会显示任何错误。
有两组代码要写:
- 在TechField中。
- 在EventHandlers中。
InvoiceTable
包括:
- TariffNumber
- ShipQty
- 量
- COO
GroupTable
包括:
- HSCODE
- 数量
- AMT
- CountryOO
EventHandlers代码如下(C#):
if (ChangedStates.Has(7)) { int currentRow = 0; int i; for (i = 0; i < Document.Field("Invoice2\\InvoiceTable").Items.Count; i++) { if (Document.Field("Invoice2\\InvoiceTable").Cell("TariffNumber", i).Value == "") { Document.Field("Invoice2\\GroupTable").Cell("HSCode", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("TariffNumber", i).Value; Document.Field("Invoice2\\GroupTable").Cell("Amt", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("Amount", i).Value; Document.Field("Invoice2\\GroupTable").Cell("Qty", currentRow).Value = Document.Field("Invoice2\\InvoiceTable").Cell("ShipQty", i).Value; currentRow++; } } }
TechField如下(JScript):
for (i = 0; i < Field("ShipQty").Items.Count - 1; i++) { for (j = i + 1; j < Field("ShipQty").Items.Count; j++) { // if same new items are found if (Field("TariffNumber").Items(i).Value == Field("TariffNumber").Items(j).Value && Field("CoO").Items(i).Value == Field("CoO").Items(j).Value) { // summarise quantities Field("ShipQty").Items(i).Value = parseInt(Field("ShipQty").Items(i).Value) + parseInt(Field("ShipQty").Items(j).Value); // and weights Field("Amount").Items(i).Value = parseFloat(Field("Amount").Items(i).Value) + parseFloat(Field("Amount").Items(j).Value); } } }
条件:
在InvoiceTable
,如果TariffNumber
和COO
相等,则应汇总ShipQty
和Amount的值并将其放入GroupTable
。
代码不显示任何错误,但也不提供输出。 如果你们中的任何人都可以帮助我,那会很棒。