|
|
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
Привет всем! Столкнулся с проблемой, что из .net во всех свойствах ячейки по формулам вижу только локализованные. На VBA все как положено. Может кто сталкивался с такой проблемой, как решали? Можно проверять, конечно, и пробовать записать на разных языках, но может есть более грамотный путь? Спасибо! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 11:11:24 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
vbapro, а проблема то в чем? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 11:27:49 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
+ не очень понятно почему отображение формул в однозначном виде - проблема.. ведь так же проще, если все формулы на одном языке.. а если вы хотите на другом, то ищите в настройках .net как обращаться из программы с заданными региональными настройками.. хотя, если честно, не понимаю в чем проблема... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 11:30:45 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
проблема в том, что язык формулы, которую видит пользователь зависит от локализации Office. Эти формулы можно увидеть в FormulaR1C1Local и FormulaLocal. В Formula и FormulaR1C1 всегда, согласно документации, формулы на английском языке. Поэтому если ваша прога использует "=сумма()" в FormulaR1C1Local и FormulaLocal, то это будет работать только на локализованной русской версии. На другой локализации будет ошибка. А если пользователей много, делать для каждого свою версию? Если вы используете Formula и FormulaR1C1, то прога работать должна во всех случаях, на VBA так и есть. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 12:12:16 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
vbapro, разве вариант на английском не работает на люьой локализации по умолчанию? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 13:59:18 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
Евгений_Анатольевичvbapro, разве вариант на английском не работает на люьой локализации по умолчанию?Именно об этом я и пишу, смотрите скрины.. :( ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 14:03:26 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
vbapro, да нет.. если почитать описание, то: стандартный хэлпFormulaR1C1 Property See AlsoApplies ToExampleSpecificsReturns or sets the formula for the object, using R1C1-style notation in the language of the macro. Read/write Variant for Range objects, read/write String for Series objects. Remarks If the cell contains a constant, this property returns the constant. If the cell is empty, the property returns an empty string. If the cell contains a formula, the property returns the formula as a string, in the same format in which it would be displayed in the formula bar (including the equal sign). If you set the value or formula of a cell to a date, Microsoft Excel checks to see whether that cell is already formatted with one of the date or time number formats. If not, the number format is changed to the default short date number format. If the range is a one- or two-dimensional range, you can set the formula to a Visual Basic array of the same dimensions. Similarly, you can put the formula into a Visual Basic array. Setting the formula of a multiple-cell range fills all cells in the range with the formula. Example This example sets the formula for cell B1 on Sheet1. Worksheets("Sheet1").Range("B1").FormulaR1C1 = "=SQRT(R1C1)" стандартный хэлпFormulaR1C1Local Property See AlsoApplies ToExampleSpecificsReturns or sets the formula for the object, using R1C1-style notation in the language of the user. Read/write Variant for Range objects, read/write String for Series objects. Remarks If the cell contains a constant, this property returns that constant. If the cell is empty, the property returns an empty string. If the cell contains a formula, the property returns the formula as a string, in the same format in which it would be displayed in the formula bar (including the equal sign). If you set the value or formula of a cell to a date, Microsoft Excel checks to see whether that cell is already formatted with one of the date or time number formats. If not, the number format is changed to the default short date number format. If the range is a one- or two-dimensional range, you can set the formula to a Visual Basic array of the same dimensions. Similarly, you can put the formula into a Visual Basic array. Setting the formula of a multiple-cell range fills all cells in the range with the formula. Example Assume that you enter the formula =SUM(A1:A10) in cell A11 on worksheet one, using the American English version of Microsoft Excel. If you then open the workbook on a computer that's running the German version and run the following example, the example displays the formula =SUMME(Z1S1:Z10S1) in a message box. MsgBox Worksheets(1).Range("A11").FormulaR1C1Local ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 14:33:35 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
может все-таки вы четко напишете что вы делаете и что не так.. так и не понятно почему это для вас проблема.. я не могу гадать на кофейной гуще.. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 14:36:16 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
http://msdn.microsoft.com/en-us/library/aa168494(office.11).aspx Если надо просто поредактировать формулы, или забрать данные с листов в каком-то одном формате проще менять культуру в потоке в котором запускаешь эксель из кода, по ссылке выше это расписано. ' Visual Basic ' Store the current CultureInfo for the thread and then set ' the thread's CultureInfo to en-US. Dim thisThread As System.Threading.Thread = _ System.Threading.Thread.CurrentThread Dim originalCulture As System.Globalization.CultureInfo = _ thisThread.CurrentCulture Dim tempExpense As Object Dim tempIncome As Object ' Use an exception block to switch back in case of a run-time error. Try thisThread.CurrentCulture = New System.Globalization.CultureInfo( _ "en-US") ' Make the call to Excel. tempExpense = expenseRange.Value2 tempIncome = incomeRange.Value2 Finally ' Restore the culture information for the thread after the ' Excel calls have completed. thisThread.CurrentCulture = originalCulture End Try If (tempExpense < tempIncome) Then MsgBox(tempExpense & " is smaller") End If ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 15:11:13 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
nporaMephttp://msdn.microsoft.com/en-us/library/aa168494(office.11).aspx Если надо просто поредактировать формулы, или забрать данные с листов в каком-то одном формате проще менять культуру в потоке в котором запускаешь эксель из кода, по ссылке выше это расписано. ' Visual Basic ' Store the current CultureInfo for the thread and then set ' the thread's CultureInfo to en-US. Dim thisThread As System.Threading.Thread = _ System.Threading.Thread.CurrentThread Dim originalCulture As System.Globalization.CultureInfo = _ thisThread.CurrentCulture Dim tempExpense As Object Dim tempIncome As Object ' Use an exception block to switch back in case of a run-time error. Try thisThread.CurrentCulture = New System.Globalization.CultureInfo( _ "en-US") ' Make the call to Excel. tempExpense = expenseRange.Value2 tempIncome = incomeRange.Value2 Finally ' Restore the culture information for the thread after the ' Excel calls have completed. thisThread.CurrentCulture = originalCulture End Try If (tempExpense < tempIncome) Then MsgBox(tempExpense & " is smaller") End If то что нужно, спасибо! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 15:42:34 |
|
||
|
Локализация формул при автоматизации
|
|||
|---|---|---|---|
|
#18+
Да, точно, временное переключение на CultureInfo("en-US") дает требуемый эффект. Для информации, формулы - это не единственный случай, когда может потребоваться изменять культуру. Например, при добавлении книг и работе с листами, появляется ошибка, связанная с багом, решить которую можно только временно изменив культуру http://support.microsoft.com/kb/320369 . ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 04.12.2008, 16:02:07 |
|
||
|
|

start [/forum/topic.php?fid=61&msg=35694133&tid=2180045]: |
0ms |
get settings: |
12ms |
get forum list: |
18ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
35ms |
get topic data: |
11ms |
get forum data: |
2ms |
get page messages: |
51ms |
get tp. blocked users: |
2ms |
| others: | 211ms |
| total: | 348ms |

| 0 / 0 |
