how to export to excel (Grouping) ?

i have several data in sales line like these :

Item No Quantity
A001 10
A002 5
A003 11
A001 10
A004 15

because Item A001 there are twice, so they should be accumulated become

i want to export the data to excel become like this

A001 20
A002 5
A003 11
A004 15

how to group them?

My code is

.

.

.

.

IF SL.FIND(’-’) THEN
Counter := Counter +1;
IF SL.COUNT > 0 THEN
BEGIN
//Fill Excel Header
Row := 1;
Window.OPEN(
Text001 +
@1@@@@@@@@@@@@@@@@@@@@@’);
Window.UPDATE(1,0);
TotalRecNo := SL.COUNTAPPROX;
RecNo :=0;
TempExcelBuffer.DELETEALL;
CLEAR(TempExcelBuffer);
//Fill Excel Body
REPEAT
SL.RESET;
SL.SETRANGE(SL.“No.”,Item.“No.”);
Row := Row + 1;
EnterCell(Row, 1, SL.“No.”, FALSE, FALSE, FALSE);
EnterCell(Row, 4, FORMAT(SL.Quantity), FALSE, FALSE, FALSE);
EnterCell(Row, 5, FORMAT(SL.“Shipment Date”), FALSE, FALSE, FALSE);
EnterCell(Row, 6, SL.“Sell-to Customer No.”, FALSE, FALSE, FALSE);
EnterCell(Row, 10, FORMAT(SL.“Requested Delivery Date”), FALSE, FALSE, FALSE);
EnterCell(Row, 11, FORMAT(SL.“Variant Code”), FALSE, FALSE, FALSE);
EnterCell(Row, 12, FORMAT(SL.“Description 2”), FALSE, FALSE, FALSE);
RecNo := RecNo + 1;
UNTIL SL.NEXT = 0;
.

.

.

.

END;

You can write a report that only outputs to Excel on the report footer.

Output the Header on the Predata Item of the main table.

actually the exportation is no problem

my question is just how to grouping the quantity if there is same item

Hi Stan,

Same as any other report i.e. sort and group - then export from the Group Footer section as Greg suggests.

Otherwise amend you code to sort by item no. and export on change of item no.

i do the calculation using temporary table

after that i export to excel

now it’s done

thanks dave for your sharing :slight_smile:

This article may be helpful for you.

http://www.c-sharpcorner.com/UploadFile/f201d9/data-export-to-excel-and-create-group-report-in-net3/