Johnny Andersson wrote:
Here are two lines from a macro I wrote to remove ' from cells in cell ranges, for example if a cell formula is '20 my macro will convert it to 20.

Selection=ThisComponent.CurrentSelection
Data=Selection.getFormulaArray

I tested the macro and all seemed to work perfectly until I tried it on a spreadsheet with floating points. The points is actually a comma, since that is Swedish standard.

So I look at a cell, which contains '0,06253
Of course 0,06253 is shown in the cell. The ' can only be seen in the cell formula field.

However, in my macro, getFormulaArray seems to return 0,06253 in this example and it seems like as soon there is a comma involved, the ' can not be detected with getFormulaArray.

Note that there is no quote in such a cell. The cell contains the text "20". If you edit the cell, a quote is prepended, so editing results in a text again. This is done if input of the cell's text, using the cell's number format (including the locale), would result in a number.

The API getFormula/setFormula methods do something similar, but not the same, because they always format/interpret numbers in en-US locale (so the same formula string can be used regardless of the user's locale).

Any suggestions for solutions for this problem?

Don't bother with quotes. Look for text that can be interpreted as a number, and replace it with that number (and don't forget that part of "can be interpreted as a number" is the handling of different locales).

Niklas

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to