We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception when using RC formula with space in sheet name

Hi,
I am using Aspose cells 8.1.0
When I exceute the following snippet for a worksheet that has space in name, it throws com.aspose.cells.CellsException: Invalid formula:"Sheet 3!$A$1:$D$4".

Code Snippet

private Range createR1C1PatternBasedRange(Workbook workbook, String R1C1pattern) {
try {
int rangeIndex = workbook.getWorksheets().getNames().add("dummyrange");
Name name = workbook.getWorksheets().getNames().get(rangeIndex);
name.setR1C1RefersTo("=sheet 3!r1c1:r4c4");
name = workbook.getWorksheets().getNames().get(rangeIndex);
return name.getRange();
} catch (Exception e) {
return null;
}
}

How do i resolve this?

Thanks,
Jaspreet

Hi,

Please update your code segment as following, see the line in bold:

e.g

Sample code:

private Range createR1C1PatternBasedRange(Workbook workbook, String R1C1pattern) {

try {

int rangeIndex = workbook.getWorksheets().getNames().add("dummyrange");

Name name = workbook.getWorksheets().getNames().get(rangeIndex);

name.setR1C1RefersTo("='sheet 3'!r1c1:r4c4");

name = workbook.getWorksheets().getNames().get(rangeIndex);

return name.getRange();

} catch (Exception e) {

return null;

}

}

Thank you.