excel RemoveDuplicates方法

w9apscun  于 2023-04-07  发布在  其他
关注(0)|答案(1)|浏览(208)

有人在Progress 4GL中使用过Excel的RemoveDuplicates方法吗?你能告诉我语法是什么吗?
VBA中的示例:

ActiveSheet.Range("A1:C100").RemoveDuplicates Columns:=Array(1,2), Header:=xlYes

以下是我在Progress 4gl中尝试的内容:

PROCEDURE pi-elimina-duplicata:

  DEFINE VARIABLE v-chr-excel-application AS COM-HANDLE NO-UNDO. 
  DEFINE VARIABLE v-chr-work-book AS COM-HANDLE NO-UNDO.
  DEFINE VARIABLE v-chr-work-sheet AS COM-HANDLE NO-UNDO.
  DEFINE VARIABLE v-chr-range AS CHARACTER NO-UNDO.
  DEFINE VARIABLE v-int-line AS INTEGER NO-UNDO INITIAL 1.
  DEFINE VARIABLE v-int-ultimalinha AS INTEGER NO-UNDO.
  DEFINE VARIABLE v-coluna-a AS CHARACTER FORMAT "X(20)".
  DEFINE VARIABLE v-coluna-b AS CHARACTER FORMAT "X(20)".
  DEFINE VARIABLE v-coluna-c AS CHARACTER FORMAT "X(20)".

  CREATE 'excel.application':U v-chr-excel-application. 
  v-chr-excel-application:VISIBLE = TRUE.
  ASSIGN
    v-chr-work-book = v-chr-excel-application:Workbooks:OPEN(c-nome-arquivo) v-chr-work-sheet = v-chr-excel-application:Sheets:ITEM(1)
    v-int-ultimalinha = v-chr-excel-application:Activesheet:Usedrange:Rows:COUNT
  .

  /* v-chr-work-sheet:Range("$A$1:$AC$568"):RemoveDuplicates:COLUMNS:Array(1, 2, 3, 4, 5, 6, , 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29):HEADER:xlYes. */

  v-chr-work-sheet:UsedRange:RemoveDuplicates("A:AC",1) /* ("1, 2, 3, 4, 5, 6, , 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29", YES) */. 

  /* Range(“A1:C8”).RemoveDuplicates Columns:=1, Header:=xlYes */

  v-chr-excel-application:Workbooks:APPLICATION:QUIT.

  RELEASE OBJECT v-chr-excel-application NO-ERROR.
  RELEASE OBJECT v-chr-work-sheet NO-ERROR.
  RELEASE OBJECT v-chr-work-book NO-ERROR.

END PROCEDURE.
2w2cym1i

2w2cym1i1#

正确的语法 * 应该 * 是:

DEFINE VARIABLE columnsArray AS INTEGER EXTENT 2 NO-UNDO.  
      
columnsArray[1] = 1 .
columnsArray[2] = 2 .
      
v-chr-work-sheet:Range("A1:A5"):RemoveDuplicates(columnsArray, 1 /* XlYesNoGuess:xlYes */ ) .

对于数组,传入一个ABL数组,头部常量需要替换为单个整数值:https://learn.microsoft.com/en-us/office/vba/api/excel.xlyesnoguess
然而代码错误,但也许这有助于你得到进一步.
访问组件属性/方法时出错:删除重复项。Ausnahmefehler aufgetreten。
错误代码:0x 80020009 test.p(5890)

相关问题