Set columns for summing up when adding a new record, if there is one already in the table (using the "add_row_sum" function).

The previous assignment of the summarized columns is cancelled.

By default, all columns are summable.

If you specify a command without a list of columns, then all columns will not be summarized.


Call:

undo the summation of all columns for the "add_row_sum" command:

ts_table(iTable,"set_columns_to_add_sum");
set summation by columns:
ts_table(iTable,"set_columns_to_add_sum",
int colnum1/string colname1,
int colnum2/string colname2,
...
int colnumN/string colnameN
);


Here:

colnumN - number of the column in which the value will be summed up if the value of the primary key (the set of columns specified in the "set_first_key" command) matches the new record;

colname1 - the same can be set with the name of the column.


Example.

Sum the amount from the iTableMatRes table by GUID to the iTableMatResTmp table and export it to Excel, changing the names and sequence of the columns.


int ires = excel_attach();

if (ires != 0)

{

       tsalert(-1, "Error", "Unable to connect to excel file", sWorkBook);

return -1;

}

ires = excel_request("workbook_select", sWorkBook);

if (ires != 0)

{

       tsalert(-1, "Error", "Can't switch to excel file", sWorkBook);

       excel_detach();

       return -1;

}


string sSheetName;

sSheetName = "Result materials";

ires = excel_request("sheet_select", sSheetName);

if (ires != 0) {

       tsalert(-1, "Error", "Can't switch to page", sSeetName);

       excel_detach();

       return -1;

}


int iTableMatResTmp;

object("create", "ts_table", iTableMatResTmp);

ts_table(iTableMatResTmp, "import_columns_from_table", iTableMatRes);

ts_table(iTableMatResTmp, "set_first_key", "GUID material");

ts_table(iTableMatResTmp, "set_columns_to_add_sum", "Count");

ts_table(iTableMatResTmp, "add_rows_from_eq_table_by_filter", iTableMatRes, false, true);


ts_table(iTableMatResTmp, "mapping_columns_to_export",

       -1, "Pos.", "",

       "Material name (Rus)", "Material name and technical specification", "",

       -1, "Production code","",

       -1, "User", "",

       "Unit", "Unit", "",

       "Count", "Count", "",

       -1, "Weight","",

       -1, "Comment", ""

       );


ts_table(iTableMatResTmp, "export_to_excel", 1, "A", 1, 0, -1);

breakpoint(101);

object("delete",iTableMatResTmp);

excel_detach();