Feedback
Did this article resolve your question/issue?

   

Article

Sample Code to do Excel Grouping

« Go Back

Information

 
TitleSample Code to do Excel Grouping
URL NameSample-Code-to-do-Excel-Grouping
Article Number000184602
EnvironmentProduct: OpenEdge
Version: 10.x, 11.x
OS: Windows
Other: Excel
Question/Problem Description
Sample Code to do Excel Grouping
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution
The following code shows how to implement grouping in Excel:
DEFINE VARIABLE chExcel     AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorksheet AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chWorkbook  AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE misValue    AS COM-HANDLE NO-UNDO.

CREATE "excel.application" chExcel.

chExcel:visible = true.

chWorkbook  = chExcel:Workbooks:Add().
chWorksheet = chWorkbook:Worksheets(1).

chWorksheet:Range("A1:B1"):NumberFormat = "@".

chWorksheet:Range("A1"):VALUE = "Name".
chWorksheet:Range("B1"):VALUE = "Function".

chWorksheet:Range("A2"):VALUE = "emp1".
chWorksheet:Range("A3"):VALUE = "emp1".
chWorksheet:Range("A4"):VALUE = "emp1".
chWorksheet:Range("A5"):VALUE = "emp2".
chWorksheet:Range("A6"):VALUE = "emp2".
chWorksheet:Range("A7"):VALUE = "emp2".
chWorksheet:Range("B2"):VALUE = "job1".
chWorksheet:Range("B3"):VALUE = "job3".
chWorksheet:Range("B4"):VALUE = "job5".
chWorksheet:Range("B5"):VALUE = "job3".
chWorksheet:Range("B6"):VALUE = "job3".
chWorksheet:Range("B7"):VALUE = "job2".

chExcel:Worksheets("Sheet1"):Activate().

/* chWorksheet.Range(1, 1).CurrentRegion.Subtotal(GroupBy:=1, Function:=-4112, TotalList:=2, Replace:=True, PageBreaks:=False, SummaryBelowData:=False) */

chWorksheet:Range("A1"):CurrentRegion:Subtotal(1, -4112, 2, True, False, False).

/* Quit Excel */

chExcel:Quit().

/* Release Com-handle  */

RELEASE OBJECT chWorksheet.
RELEASE OBJECT chWorkbook.
RELEASE OBJECT chExcel.

 
Workaround
Notes
Last Modified Date8/1/2016 11:32 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.