id_spreadsheet = par_id;
cou_logError( cnx, CO_LOG_DEBUG, "getCellRefs called");

/* cells referenced */
__CREATE_QUERY( "
SELECT EXPR.id_column, EXPR.id_row, EXPR.index_ref,
EXPR.id_ref_column, EXPR.id_ref_row, EXPR.is_ref_column_hard, EXPR.is_ref_row_hard,
EXPR.is_ref_column_named, EXPR.is_ref_row_named
FROM co_sys_spreadsheet_row AS TR,co_sys_spreadsheet_column AS TC, co_sys_expression_cell AS EXPR
WHERE
TR.spreadsheet_id = %d AND
TC.spreadsheet_id = %d AND
EXPR.id_column=TC.id AND
EXPR.id_row=TR.id ;
", id_spreadsheet, id_spreadsheet)

__SQL_GET_RESULT

ntuples = cor_GetTupleCount(cnx, corec);
for (nr=0; nr<ntuples; nr++) {
ap_rprintf( r, "arrExpRefCells['%s_%s_%s']='%s,%s,%s,%s,%s,%s';\n",
cor_GetValue(cnx, corec,nr,0),cor_GetValue(cnx, corec,nr,1),cor_GetValue(cnx, corec,nr,2),
cor_GetValue(cnx, corec,nr,3),cor_GetValue(cnx, corec,nr,4),
cor_GetValue(cnx, corec,nr,5),cor_GetValue(cnx, corec,nr,6),cor_GetValue(cnx, corec,nr,7),cor_GetValue(cnx, corec,nr,8)
);
}

__CLEAR_RESULT

/* ranges referenced */
__CREATE_QUERY( "
SELECT EXPR.id_column, EXPR.id_row, EXPR.index_ref,
EXPR.id_ref_column, EXPR.id_ref_row,
EXPR.is_ref_column_hard, EXPR.is_ref_row_hard,
EXPR.is_ref_column_named, EXPR.is_ref_row_named,
EXPR.id_ref_column2, EXPR.id_ref_row2,
EXPR.is_ref_column2_hard, EXPR.is_ref_row2_hard,
EXPR.is_ref_column2_named, EXPR.is_ref_row2_named
FROM co_sys_spreadsheet_row AS TR,co_sys_spreadsheet_column AS TC, co_sys_expression_range AS EXPR
WHERE
TR.spreadsheet_id = %d AND
TC.spreadsheet_id = %d AND
EXPR.id_column=TC.id AND
EXPR.id_row=TR.id ;
", id_spreadsheet, id_spreadsheet)

__SQL_GET_RESULT

ntuples = cor_GetTupleCount(cnx, corec);
for (nr=0; nr<ntuples; nr++) {
ap_rprintf( r, "arrExpRefRanges['%s_%s_%s']='%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s';\n",
cor_GetValue(cnx, corec,nr,0),cor_GetValue(cnx, corec,nr,1),cor_GetValue(cnx, corec,nr,2),
cor_GetValue(cnx, corec,nr,3),cor_GetValue(cnx, corec,nr,4),cor_GetValue(cnx, corec,nr,5),cor_GetValue(cnx, corec,nr,6),
cor_GetValue(cnx, corec,nr,7),cor_GetValue(cnx, corec,nr,8),cor_GetValue(cnx, corec,nr,9),cor_GetValue(cnx, corec,nr,10),
cor_GetValue(cnx, corec,nr,11),cor_GetValue(cnx, corec,nr,12),cor_GetValue(cnx, corec,nr,13),cor_GetValue(cnx, corec,nr,14)
);
}

__CLEAR_RESULT

cou_logError( cnx, CO_LOG_DEBUG, "getCellRefs done");