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

Free Support Forum - aspose.com

Get range from Excel when Office Programs are Launched in Spanish/French Language

Hi,

I am using Aspose.Cells 8.5.2
We refer to a range in RC reference style as R1C1:R2C2.
But for a Spanish Locale, this will be understood as F1C1:F2C2

I used the following code to get range,but failed.
1. trial 1 via RC pattern
int rangeIndex = workbook.getWorksheets().getNames().add(“dummyrange”);
Name name = workbook.getWorksheets().getNames().get(rangeIndex);
name.setR1C1RefersTo(“F1C1:F2C2”);
name = workbook.getWorksheets().getNames().get(rangeIndex);
return name.getRange();

2. Trial 2 via
dynamicRange = selectedWorksheet.getCells().createRange(“F1c1:f2c2”);

I also tried by setting java.Util Locale to es_ES or es_CA, but that did not work.
How do I meet this requirement?

The requirement if for dynamic ranges represented
  • In French as L1C1:L5C5
  • In Spanish as F1C1:F5C5

Thanks,
Jaspreet

Hi,


Could you try the following sample code if it makes any difference:
e.g
Sample code:

//Locale locale = new Locale(“es”, “ES”);
Workbook workbook = new Workbook();
//Or
workbook.getSettings().setRegion(CountryCode.SPAIN);
int rangeIndex = workbook.getWorksheets().getNames().add(“dummyrange”);
Name name = workbook.getWorksheets().getNames().get(rangeIndex);
name.setR1C1RefersTo(“R1C1:R2C2”);
name = workbook.getWorksheets().getNames().get(rangeIndex);

If you still find any issue, kindly provide a sample Excel file created in Spanish environment, we will check it soon.

Thank you.

Hi,

I would like to restate my problem, that is if we select a range, for eg A1:C3 in a worksheet that is identified out to be R1C1:R3C3 in terms of RC formula.

But for a Excel opened in Spanish language ‘Hoja1’!F1C1:F3C1 will be obtained from clipboard… and if this range is passed to cells API like name.setR1C1RefersTo(‘Hoja1’!F1C1:F3C1); then

name.getRange() API returns null as shown in the code below.

private Range createR1C1PatternBasedRange(Workbook workbook, String R1C1pattern) {

try {

//workbook.getSettings().setRegion(CountryCode.SPAIN);

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

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

name.setR1C1RefersTo(R1C1pattern);

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

return name.getRange();

} catch (Exception e) {

return null;

}

}

So I am looking for a way/API such that if locale spansih is set then F1C1:F3C3 can be intepreted as R1C1:R3C3

I tried with the locale options mentioned in above thread but they did not work.

For reference I have attached a Excel doc created in Spanish.

I changed the language settings by

In MS Excel goto–>Options->Language->Choose Display and Help Languages

Thanks,

Jaspreet

Hi,


Please note the following when specifying RefersTo formula for the range by Aspose.Cells APIs:

Formulas must be entered in English Excel style. For example, use the English “=SUM()” not the German “=SUMME()”, so you cannot apply as “setR1C1RefersTo(‘Hoja1’!F1C1:F3C1)” (Spanish oriented) instead, it won’t create the range.

When you set the locale in your code or set region/ language settings by using control panel (of the OS) options, these things are useful when you want to display numbers formattings in your desired regional settings. For example, you want to render numbers should be displayed in your desired locale (as per your locale/region set in your code) in the output PDF file.

Thanks for your understanding!