* you want to set as a title e.g. $A:$B for columns A and B
*/
// note: MUST be in $ROW:$ROW or $COL:$COL format, for both
// can be $R:$R, $C:$C for both
public void setTitles (String range) {
Name name = sheet.getName( "Built-in: PRINT_TITLES" );
if (name == null) try {
name = new Name( sheet.getWorkBook(), "Print_Titles" );
name.setBuiltIn( (byte)0x07 ); //do before setNewScope as it blows out itab
name.setNewScope( sheet.getSheetNum() + 1 );
} catch (WorkSheetNotFoundException e) {
// This shouldn't be possible.
throw new Error ("sheet not found re-scoping name");
}
// pre-process range to ensure in proper format, ensure all absolute ($) refs +
// handle wholerow-wholecol refs + complex ranges
if (range==null) return; // TODO: Do what?? remove??
String[] ranges= range.split(",");
range= "";
for (int i= 0; i < ranges.length; i++) {
if (i > 0) // concatenate terms into one ptgmemfunc-style expression
range+=",";
String r= "";
int[] rc= ExcelTools.getRangeCoords(ranges[i]);
if (rc[0]==rc[2]) // varies by column
r= "$" + ExcelTools.getAlphaVal(rc[1]) + ":$" + ExcelTools.getAlphaVal(rc[3]);
if (rc[1]==rc[3]) {// varies by row
r= "$" + rc[0] + ":$" + rc[2];
}
range+= sheet.getSheetName() + "!" + r;
}
name.setLocation( range );
}