使用合并单元格将4gl导出到Excel 如何在中间用合并单元格从进度导出到Excel?当我试图出口时,它自己也没有合并。 预期产出示例:

使用合并单元格将4gl导出到Excel 如何在中间用合并单元格从进度导出到Excel?当我试图出口时,它自己也没有合并。 预期产出示例:,excel,merge,cell,progress-4gl,openedge,Excel,Merge,Cell,Progress 4gl,Openedge,值为1的合并单元格(3个单元格)其他值1其他值1 值为2的合并单元格(3个单元格)其他值2其他值2 值为3的合并单元格(3个单元格)其他值3其他值3 我的输出是: 未合并单元格值1其他值1其他值1 未合并单元格值2其他值2其他值2 未合并单元格值3其他值3其他值3 我的导出到excel代码: DEFINE VARIABLE h-excel AS COM-HANDLE NO-UNDO. DEFINE VARIABLE h-sheet AS COM-HANDLE. DEFINE VAR w-invn

值为1的合并单元格(3个单元格)
其他值1
其他值1

值为2的合并单元格(3个单元格)
其他值2
其他值2

值为3的合并单元格(3个单元格)
其他值3
其他值3

我的输出是:

未合并单元格值1
其他值1
其他值1

未合并单元格值2
其他值2
其他值2

未合并单元格值3
其他值3
其他值3

我的导出到excel代码:

DEFINE VARIABLE h-excel AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE h-sheet AS COM-HANDLE.
DEFINE VAR w-invname AS CHAR INITIAL "insert excel fill here".
CREATE "Excel.Application" h-excel.

h-sheet = h-excel:Workbooks:OPEN (w-invname,,FALSE,,,,,,,,,,FALSE) NO-ERROR.
h-excel:visible = true.

h-excel:Cells:Select.
/*h-excel:Selection:ClearContents.*/

h-excel:Run("loading").  /* Run the Macro, up to 31 optional   */
                           /* parameters can be passed           */
/*h-excel:Quit().*/            /* Tell Excel to quit                 */

/*h-excel:Range("A" + STRING(5)):VALUE = "Date Covered " + STRING(fifr) + " - " + STRING(fito).*/
h-excel:Range("A" + STRING(6)):VALUE = "As of " + cbMon + STRING(fiyear).

h-excel:Range("A12"):Select.
/*h-excel:Workbooks:SaveAs("c:\hckiv9\crd\forms\KMCDAT1.xls",43,,,,,).*/

RELEASE OBJECT h-sheet.
RELEASE OBJECT h-excel.

END PROCEDURE.

我不知道我是否正确理解了您的意图,但是您提供的示例中没有可以合并的代码。下面是我快速整理的一些东西:

DEFINE VARIABLE chExcel       AS COM-HANDLE      NO-UNDO.
DEFINE VARIABLE chSpreadsheet AS COM-HANDLE      NO-UNDO.

/* Excel Creation, not relevant to the question, but preparing the answer */
create "Excel.Application" chExcel.
chExcel:WorkBooks:add. 
chExcel:sheets:item(1).
chSpreadsheet = chExcel:Worksheets("Sheet1").

   /* This line merges the two cells */
   chSpreadsheet:range('b2:c2'):merge().

   /* This line selects the merged cells */
   chSpreadsheet:range('b2:b2'):select().

   /* The next puts a value to B2 (Which is now merged with C2) */
   chSpreadsheet:cells(2,2) = 'test'.

   /* Make Excel visible to the user */
   chExcel:visible = true.

   /* Release handles, you may dispose of Excel here and add a quit if you 
      don't want to leave the screen hanging for the user */
   chSpreadsheet = ?.
   chExcel = ?.
所以,实际上回答你问题的那一行是我在Excel启动后进行的合并。现在,据我所知,range不同于单元格(在单元格中可以提供两个逗号分隔的整数),它需要一个范围字符串(在我们的例子中是B2:c2。但是您可以根据需要更改它)。如果我忽略了你需要的任何东西,请告诉我。希望这有帮助