MS Excel columns have a pattern like A, B, C, …, Z, AA, AB, AC, …., AZ, BA, BB, … ZZ, AAA, AAB ….. etc. In other words, column 1 is named “A”, column 2 as “B”, and column 27 as “AA”.
Given a column number, find its corresponding Excel column name. The following are more examples.
Input Output 26 Z 51 AY 52 AZ 80 CB 676 YZ 702 ZZ 705 AAC
Thanks to Mrigank Dembla for suggesting the below solution in a comment.
Suppose we have a number n, let’s say 28. so corresponding to it we need to print the column name. We need to take the remainder with 26.
If the remainder with 26 comes out to be 0 (meaning 26, 52, and so on) then we put ‘Z’ in the output string and new n becomes n/26 -1 because here we are considering 26 to be ‘Z’ while in actuality it’s 25th with respect to ‘A’.
Similarly, if the remainder comes out to be non-zero. (like 1, 2, 3, and so on) then we need to just insert the char accordingly in the string and do n = n/26.
Finally, we reverse the string and print.
Example:
n = 700
The remainder (n%26) is 24. So we put ‘X’ in the output string and n becomes n/26 which is 26.
Remainder (26%26) is 0. So we put ‘Z’ in the output string and n becomes n/26 -1 which is 0.
Following is the implementation of the above approach.
C++
#include <bits/stdc++.h>
#define MAX 50
using
namespace
std;
void
printString(
int
n)
{
char
str[MAX];
int
i = 0;
while
(n > 0) {
int
rem = n % 26;
if
(rem == 0) {
str[i++] =
'Z'
;
n = (n / 26) - 1;
}
else
{
str[i++] = (rem - 1) +
'A'
;
n = n / 26;
}
}
str[i] =
''
;
reverse(str, str +
strlen
(str));
cout << str << endl;
return
;
}
int
main()
{
printString(26);
printString(51);
printString(52);
printString(80);
printString(676);
printString(702);
printString(705);
return
0;
}
Java
public
class
ExcelColumnTitle {
private
static
void
printString(
int
columnNumber)
{
StringBuilder columnName =
new
StringBuilder();
while
(columnNumber >
0
) {
int
rem = columnNumber %
26
;
if
(rem ==
0
) {
columnName.append(
"Z"
);
columnNumber = (columnNumber /
26
) -
1
;
}
else
{
columnName.append((
char
)((rem -
1
) +
'A'
));
columnNumber = columnNumber /
26
;
}
}
System.out.println(columnName.reverse());
}
public
static
void
main(String[] args)
{
printString(
26
);
printString(
51
);
printString(
52
);
printString(
80
);
printString(
676
);
printString(
702
);
printString(
705
);
}
}
Python
MAX
=
50
def
printString(n):
string
=
[
""
]
*
MAX
i
=
0
while
n >
0
:
rem
=
n
%
26
if
rem
=
=
0
:
string[i]
=
'Z'
i
+
=
1
n
=
(n
/
26
)
-
1
else
:
string[i]
=
chr
((rem
-
1
)
+
ord
(
'A'
))
i
+
=
1
n
=
n
/
26
string[i]
=
''
string
=
string[::
-
1
]
print
"".join(string)
printString(
26
)
printString(
51
)
printString(
52
)
printString(
80
)
printString(
676
)
printString(
702
)
printString(
705
)
C#
using
System;
class
GFG{
static
String reverse(String input)
{
char
[] reversedString = input.ToCharArray();
Array.Reverse(reversedString);
return
new
String(reversedString);
}
private
static
void
printString(
int
columnNumber)
{
String columnName =
""
;
while
(columnNumber > 0)
{
int
rem = columnNumber % 26;
if
(rem == 0)
{
columnName +=
"Z"
;
columnNumber = (columnNumber / 26) - 1;
}
else
{
columnName += (
char
)((rem - 1) +
'A'
);
columnNumber = columnNumber / 26;
}
}
columnName = reverse(columnName);
Console.WriteLine(columnName.ToString());
}
public
static
void
Main(String[] args)
{
printString(26);
printString(51);
printString(52);
printString(80);
printString(676);
printString(702);
printString(705);
}
}
Javascript
<script>
function
printString(columnNumber)
{
let columnName = [];
while
(columnNumber > 0) {
let rem = columnNumber % 26;
if
(rem == 0) {
columnName.push(
"Z"
);
columnNumber = Math.floor(columnNumber / 26) - 1;
}
else
{
columnName.push(String.fromCharCode((rem - 1) +
'A'
.charCodeAt(0)));
columnNumber = Math.floor(columnNumber / 26);
}
}
document.write(columnName.reverse().join(
""
)+
"<br>"
);
}
printString(26);
printString(51);
printString(52);
printString(80);
printString(676);
printString(702);
printString(705);
</script>
Output
Z AY AZ CB YZ ZZ AAC
Time Complexity: O(log26n), as we are using a loop and in each traversal, we decrement by floor division of 26.
Auxiliary Space: O(50), as we are using extra space for storing the result.
Method 2
The problem is similar to converting a decimal number to its binary representation but instead of a binary base system where we have two digits only 0 and 1, here we have 26 characters from A-Z.
So, we are dealing with base 26 instead of base binary.
That’s not where the fun ends, we don’t have zero in this number system, as A represents 1, B represents 2 and so on Z represents 26.
To make the problem easily understandable, we approach the problem in two steps:
- Convert the number to base 26 representation, considering we have 0 also in the system.
- Change the representation to the one without having 0 in its system.
HOW? Here is an example
Step 1:
Consider we have number 676, How to get its representation in the base 26 system? In the same way, we do for a binary system, Instead of division and remainder by 2, we do division and remainder by 26.
Base 26 representation of 676 is : 100
Step2
But Hey, we can’t have zero in our representation. Right? Because it’s not part of our number system. How do we get rid of zero? Well it’s simple, but before doing that let’s remind one simple math trick:
Subtraction: 5000 - 9, How do you subtract 9 from 0 ? You borrow from next significant bit, right.
- In a decimal number system to deal with zero, we borrow 10 and subtract 1 from the next significant.
- In the Base 26 Number System to deal with zero, we borrow 26 and subtract 1 from the next significant bit.
So Convert 10026 to a number system that does not have ‘0’, we get (25 26)26
Symbolic representation of the same is: YZ
Here is the implementation of the same:
C++
#include <iostream>
using
namespace
std;
void
printString(
int
n)
{
int
arr[10000];
int
i = 0;
while
(n) {
arr[i] = n % 26;
n = n / 26;
i++;
}
for
(
int
j = 0; j < i - 1; j++) {
if
(arr[j] <= 0) {
arr[j] += 26;
arr[j + 1] = arr[j + 1] - 1;
}
}
for
(
int
j = i; j >= 0; j--) {
if
(arr[j] > 0)
cout <<
char
(
'A'
+ arr[j] - 1);
}
cout << endl;
}
int
main()
{
printString(26);
printString(51);
printString(52);
printString(80);
printString(676);
printString(702);
printString(705);
return
0;
}
Java
import
java.util.*;
class
GFG{
static
void
printString(
int
n)
{
int
[]arr =
new
int
[
10000
];
int
i =
0
;
while
(n >
0
)
{
arr[i] = n %
26
;
n = n /
26
;
i++;
}
for
(
int
j =
0
; j < i -
1
; j++)
{
if
(arr[j] <=
0
)
{
arr[j] +=
26
;
arr[j +
1
] = arr[j +
1
] -
1
;
}
}
for
(
int
j = i; j >=
0
; j--)
{
if
(arr[j] >
0
)
System.out.print(
(
char
)(
'A'
+ arr[j] -
1
));
}
System.out.println();
}
public
static
void
main(String[] args)
{
printString(
26
);
printString(
51
);
printString(
52
);
printString(
80
);
printString(
676
);
printString(
702
);
printString(
705
);
}
}
Python3
def
printString(n):
arr
=
[
0
]
*
10000
i
=
0
while
(n >
0
):
arr[i]
=
n
%
26
n
=
int
(n
/
/
26
)
i
+
=
1
for
j
in
range
(
0
, i
-
1
):
if
(arr[j] <
=
0
):
arr[j]
+
=
26
arr[j
+
1
]
=
arr[j
+
1
]
-
1
for
j
in
range
(i,
-
1
,
-
1
):
if
(arr[j] >
0
):
print
(
chr
(
ord
(
'A'
)
+
(arr[j]
-
1
)), end
=
"");
print
();
if
__name__
=
=
'__main__'
:
printString(
26
);
printString(
51
);
printString(
52
);
printString(
80
);
printString(
676
);
printString(
702
);
printString(
705
);
C#
using
System;
class
GFG{
static
void
printString(
int
n)
{
int
[]arr =
new
int
[10000];
int
i = 0;
while
(n > 0)
{
arr[i] = n % 26;
n = n / 26;
i++;
}
for
(
int
j = 0; j < i - 1; j++)
{
if
(arr[j] <= 0)
{
arr[j] += 26;
arr[j + 1] = arr[j + 1] - 1;
}
}
for
(
int
j = i; j >= 0; j--)
{
if
(arr[j] > 0)
Console.Write((
char
)(
'A'
+
arr[j] - 1));
}
Console.WriteLine();
}
public
static
void
Main(String[] args)
{
printString(26);
printString(51);
printString(52);
printString(80);
printString(676);
printString(702);
printString(705);
}
}
Javascript
<script>
function
printString(n){
let arr = [];
let i = 0;
while
(n) {
arr[i] = n % 26;
n = Math.floor(n / 26);
i++;
}
for
(let j = 0; j < i - 1; j++) {
if
(arr[j] <= 0) {
arr[j] += 26;
arr[j + 1] = arr[j + 1] - 1;
}
}
let ans =
''
;
for
(let j = i; j >= 0; j--) {
if
(arr[j] > 0)
ans += String.fromCharCode(65 + arr[j] - 1);
}
document.write(ans +
"<br>"
);
}
printString(26);
printString(51);
printString(52);
printString(80);
printString(676);
printString(702);
printString(705);
</script>
Output
Z AY AZ CB YZ ZZ AAC
Time Complexity: O(log26n), as we are using a loop and in each traversal, we decrement by floor division of 26.
Auxiliary Space: O(10000), as we are using extra space for the array.
Method 3:
We can use a recursive function which definitely reduces the time and increase the efficiency:
Alphabets are in sequential order like: ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’. You have experienced while using excel when you see columns and rows numbering are done in Alphabetical ways.
Here’s How I purposefully think about the logic of how it is arranged.
(In Mathematical terms, [a , b ] means from ‘a’ to ‘b’).
[1,26] = [A,Z] (Understand by ‘1’ stands for ‘A’ and ’26” stands for “Z”). For [27,52] ,it will be like [AA,AZ], For [57,78] it will be [BA,BZ]
Logic is to append an Alphabet sequentially whenever it ends up numbering at 26.
For example, if the number is ’27’ which is greater than ’26’, then we simply need to divide by 26, and we get the remainder as 1, We see “1” as “A” and can be recursively done.
we will be using python for this.
Algorithm is:
1. Take an array and Sort the letters from A to Z . (You can also use the import string and string function to get “A to Z” in uppercase.)
2. If the number is less than or equal to ’26’, simply get the letter from the array and print it.
3. If it is greater than 26, use the Quotient Remainder rule, if the remainder is zero, there are 2 possible ways, if the quotient is “1”, simply hash out the letter from the index [r-1]( ‘r’ is remainder), else call out the function from the num =(q-1) and append at the front to the letter indexing [r-1].
4. If the remainder is not equal to “0”, call the function for the num = (q) and append at the front to the letter indexing [r-1].
The code concerned with this is:
C++
#include<bits/stdc++.h>
using
namespace
std;
string alpha =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
string num_hash(
int
num){
if
(num < 26){
string res =
""
;
res += alpha[num-1];
return
res;
}
else
{
int
q = (num / 26);
int
r = num % 26;
string res =
""
;
if
(r == 0){
if
(q == 1){
res.append(1,alpha[(26 + r-1)%26]);
}
else
{
res = num_hash(q-1);
res.append(1,alpha[(26 + r-1)%26]);
}
}
else
{
res = num_hash(q);
res.append(1,alpha[(26 + r-1)%26]);
}
return
res;
}
}
int
main () {
cout<< num_hash(26) << endl;
cout<< num_hash(51) << endl;
cout<< num_hash(52) << endl;
cout<< num_hash(80) << endl;
cout<< num_hash(676) << endl;
cout<< num_hash(702) << endl;
cout<< num_hash(705) << endl;
return
0;
}
Java
import
java.io.*;
class
GFG
{
static
String alpha =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
static
String num_hash(
int
num){
if
(num <
26
)
return
Character.toString(alpha.charAt(num-
1
));
else
{
int
q = Math.floorDiv(num,
26
);
int
r = num %
26
;
if
(r ==
0
){
if
(q ==
1
){
return
Character.toString(alpha.charAt((
26
+ r-
1
)%
26
));
}
else
return
num_hash(q-
1
) + alpha.charAt((
26
+ r-
1
)%
26
);
}
else
return
num_hash(q) + alpha.charAt((
26
+ r-
1
)%
26
);
}
}
public
static
void
main (String[] args) {
System.out.println(num_hash(
26
));
System.out.println(num_hash(
51
));
System.out.println(num_hash(
52
));
System.out.println(num_hash(
80
));
System.out.println(num_hash(
676
));
System.out.println(num_hash(
702
));
System.out.println(num_hash(
705
));
}
}
Python3
alpha
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def
num_hash(num):
if
num <
26
:
return
alpha[num
-
1
]
else
:
q, r
=
num
/
/
26
, num
%
26
if
r
=
=
0
:
if
q
=
=
1
:
return
alpha[r
-
1
]
else
:
return
num_hash(q
-
1
)
+
alpha[r
-
1
]
else
:
return
num_hash(q)
+
alpha[r
-
1
]
print
(num_hash(
26
))
print
(num_hash(
51
))
print
(num_hash(
52
))
print
(num_hash(
80
))
print
(num_hash(
676
))
print
(num_hash(
702
))
print
(num_hash(
705
))
C#
using
System;
class
GFG
{
static
string
alpha =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
static
string
num_hash(
int
num){
if
(num < 26)
return
Char.ToString(alpha[num-1]);
else
{
int
q = num/26;
int
r = num % 26;
if
(r == 0){
if
(q == 1){
return
Char.ToString(alpha[(26 + r-1)%26]);
}
else
return
num_hash(q-1) + alpha[(26 + r-1)%26];
}
else
return
num_hash(q) + alpha[(26 + r-1)%26];
}
}
public
static
void
Main(String[] args) {
Console.WriteLine(num_hash(26));
Console.WriteLine(num_hash(51));
Console.WriteLine(num_hash(52));
Console.WriteLine(num_hash(80));
Console.WriteLine(num_hash(676));
Console.WriteLine(num_hash(702));
Console.WriteLine(num_hash(705));
}
}
Javascript
<script>
let alpha =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
function
num_hash(num)
{
if
(num < 26)
return
alpha[num-1]
else
{
let q = Math.floor(num/26),r = num % 26
if
(r == 0){
if
(q == 1)
return
alpha[(26 + r-1)]
else
return
num_hash(q-1) + alpha[(26 + r-1)]
}
else
return
num_hash(q) + alpha[r-1]
}
}
document.write(num_hash(26),
"</br>"
)
document.write(num_hash(51),
"</br>"
)
document.write(num_hash(52),
"</br>"
)
document.write(num_hash(80),
"</br>"
)
document.write(num_hash(676),
"</br>"
)
document.write(num_hash(702),
"</br>"
)
document.write(num_hash(705),
"</br>"
)
</script>
Output
Z AY AZ CB YZ ZZ AAC
Time Complexity: O(log26n), as we are using recursion and in each recursive call, we decrement by floor division of 26.
Auxiliary Space: O(1), as we are not using any extra space.
Related Article :
Find the Excel column number from the column title
This article is contributed by Kartik. Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.
Alxb82 Пользователь Сообщений: 6 |
Здравствуйте. Подскажите пожалуйста, как, не используя VBS определить буквенное имя столбца ячейки. Решено: Изменено: Alxb82 — 13.10.2014 19:56:07 |
The_Prist Пользователь Сообщений: 14181 Профессиональная разработка приложений для MS Office |
Не уверен, что нужно Вам именно имя столбца — ни одна функция не просит его. Номер — да. А номер можно узнать функцией СТОЛБЕЦ() Даже самый простой вопрос можно превратить в огромную проблему. Достаточно не уметь формулировать вопросы… |
Pelena Пользователь Сообщений: 1416 |
#3 13.10.2014 15:20:42 Если всё же нужна буква, то
|
||
Сергей Пользователь Сообщений: 11251 |
#4 13.10.2014 15:23:07
Лень двигатель прогресса, доказано!!! |
||
Alxb82 Пользователь Сообщений: 6 |
Задача несколько сложнее обстоит. Решаю ее разбив на множество мелких. Это одна из них. Изменено: Alxb82 — 13.10.2014 15:25:30 |
Alxb82 Пользователь Сообщений: 6 |
Сергей, — точно, работает, то что нужно — сейчас буду разбираться как работает. Спасибо. |
такую задачу решает другая формула =ДВССЫЛ(АДРЕС(2;2)) |
|
Alxb82 Пользователь Сообщений: 6 |
Все верно, но требуется ввести адрес не номером столбца а его именем. В любом случае придется переводить что-то во что-то. Например если нужно ввести текстом (не указать мышкой) столбец с именем «DU». Не считать же какой он там по счету. |
The_Prist Пользователь Сообщений: 14181 Профессиональная разработка приложений для MS Office |
#9 13.10.2014 15:43:14
Что мешает указать ссылку на эту ячейку в СТОЛБЕЦ() ? Даже самый простой вопрос можно превратить в огромную проблему. Достаточно не уметь формулировать вопросы… |
||
Alxb82 Пользователь Сообщений: 6 |
Мешает то, что я, на этапе «программирования» не знаю что это будет именно «DU». Это имя мне будет известно в процессе анализа заполненной таблицы. Я согласен что можно выкрутиться и этим способом (получить не имя а ссылку на ячейку) и в каком-то случае он будет оправдан, но в данный момент меня интересовало получить именно буквенное и только имя столбца. Спасибо. Изменено: Alxb82 — 13.10.2014 19:57:18 |
V Пользователь Сообщений: 5018 |
#11 13.10.2014 16:20:38 если озвучите всю задачу то возможно и ДВССЫЛ не понадобится. Хотя это уже другая тема.
|
||
Alxb82 Пользователь Сообщений: 6 |
#12 13.10.2014 19:18:07 Видимо, самое элегантное решение это:
где из строки адреса «строкастолбец» просто удаляется «строка» и остается «столбец».
тоже абсолютно рабочий вариант решения. |
||||
Буквенное обозначение столбца по номеру |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
||||||||
Ответить |
0 / 0 / 0 Регистрация: 13.02.2012 Сообщений: 18 |
|
1 |
|
14.02.2012, 21:04. Показов 23466. Ответов 12
Есть ли в VBA функция переводящая номер столбца в его буквенный эквивалент в Excel’е?
0 |
Казанский 15136 / 6410 / 1730 Регистрация: 24.09.2011 Сообщений: 9,999 |
||||||||||||||||
14.02.2012, 22:08 |
2 |
|||||||||||||||
РешениеНапример столбец 56
Или так
Добавлено через 24 минуты
Еще У меня получилась такая функция:
Она работает в 25 раз быстрее, чем функция, основанная на Application.ConvertFormula
4 |
аналитика здесь больше нет… 3372 / 1670 / 184 Регистрация: 03.02.2010 Сообщений: 1,219 |
||||
15.02.2012, 10:45 |
3 |
|||
вариант
1 |
KoGG 5590 / 1580 / 406 Регистрация: 23.12.2010 Сообщений: 2,366 Записей в блоге: 1 |
||||
15.02.2012, 16:02 |
4 |
|||
Еще
Она работает в 25 раз быстрее, чем функция, основанная на Application.ConvertFormula Функция Num2ABC работает неправильно , при x = 26 Num2ABC=A@ и так далее.
1 |
m-ch 6169 / 934 / 309 Регистрация: 25.02.2011 Сообщений: 1,359 Записей в блоге: 1 |
||||
15.02.2012, 17:17 |
5 |
|||
Функция Num2ABC работает неправильно , при x = 26 Num2ABC=A@ и так далее
2 |
KoGG 5590 / 1580 / 406 Регистрация: 23.12.2010 Сообщений: 2,366 Записей в блоге: 1 |
||||
15.02.2012, 17:39 |
6 |
|||
Вот правильная функция:
1 |
m-ch 6169 / 934 / 309 Регистрация: 25.02.2011 Сообщений: 1,359 Записей в блоге: 1 |
||||
15.02.2012, 17:44 |
7 |
|||
или так:
2 |
KoGG 5590 / 1580 / 406 Регистрация: 23.12.2010 Сообщений: 2,366 Записей в блоге: 1 |
||||
15.02.2012, 17:46 |
8 |
|||
Это лучше
2 |
Piramidon 0 / 0 / 0 Регистрация: 13.02.2012 Сообщений: 18 |
||||
16.02.2012, 11:48 [ТС] |
9 |
|||
или так:
Вы бы не могли написать комменты к проге… Не понятно это Num2ABC = Chr$(65 + (x — 1) Mod 26) & Num2ABC… Вообще не могу понять, что происходит в этом выражении…
0 |
0 / 0 / 0 Регистрация: 01.11.2012 Сообщений: 20 |
|
09.02.2016, 15:30 |
10 |
Узнаём имя 6-го столбца Коротко и ясно!!! Спасибо большое очень пригодилось.
0 |
Модератор 11336 / 4655 / 748 Регистрация: 07.08.2010 Сообщений: 13,484 Записей в блоге: 4 |
|
09.02.2016, 16:49 |
11 |
а есть ли обратная функция
0 |
m-ch 6169 / 934 / 309 Регистрация: 25.02.2011 Сообщений: 1,359 Записей в блоге: 1 |
||||
09.02.2016, 16:56 |
12 |
|||
0 |
Казанский 15136 / 6410 / 1730 Регистрация: 24.09.2011 Сообщений: 9,999 |
||||
09.02.2016, 23:06 |
13 |
|||
shanemac51, можно по аналогии
тест в Immediate Код ?abc2num("FJD"),columns("FJD").column 4320 4320
2 |
08.11.16 — 18:00
Столбцы в таблице нумеруются буквыми так: A, B, C, … Y, Z, AA, AB, AC, … и т.д.
Задача оптимальным способом по номеру столбца получить его букву. Например:
0 => A
25 => Z
99 => ?
На любом языке программирования.
1 — 08.11.16 — 18:17
целое от деления на 25, потом остаток от деления
через кейс определить буквы
2 — 08.11.16 — 18:20
Это называется перевод в другую систему счисления
3 — 08.11.16 — 19:15
Ну. Кто первый догадается?
4 — 08.11.16 — 19:17
а.. то есть тут призы?
5 — 08.11.16 — 19:30
(0)
системы счисления на информатике в школе проходят.
Вам на подростковый форум.
6 — 08.11.16 — 20:29
Система счисления с переменной базой — младший разряд 26, а остальные — 27.
7 — 08.11.16 — 20:36
В цикле заполнить соответствие…
8 — 08.11.16 — 20:42
(6) ТС просто скосячил, в екселе нумерация с 1 а не с 0, так что никакой переменной базы
9 — 08.11.16 — 21:41
http://catalog.mista.ru/public/544232/
Можно получить индекс зная смещение символа 64 относительно 1 и 26 разрядную систему
10 — 08.11.16 — 21:43
Или можно заполнить колонки
Функция ЗаписатьКолонки(Колонки,НачСтр,Разряд,КоличествоРазрядов,Сравнивать,ПоследняяКолонка)
// Процедура создает колонки которые меньше или равны имени последней колоки
// A,B,..,AA..ABC
Для сч=КодСимвола(«A») по КодСимвола(«Z») Цикл
НовСтр=НачСтр+Символ(сч);
Если Разряд<КоличествоРазрядов Тогда
рез= ЗаписатьКолонки(Колонки,НовСтр,Разряд+1,КоличествоРазрядов,Сравнивать,ПоследняяКолонка);
Если Сравнивать и Рез Тогда
возврат истина
КонецЕсли;
Иначе
Колонки.Добавить(НовСтр,ОписаниеСтроки());
Если Сравнивать и НовСтр=ПоследняяКолонка Тогда
возврат истина
КонецЕсли
КонецЕсли;
КонецЦикла;
возврат ложь;
КонецФункции
Процедура СоздатьКолонки(Колонки,ПоследняяКолонка)
// Создадим колонки учитывая разряды
// Например если имя последней колоки ABC то колонки идут по разрядно
//A..Z
//AA..ZZ
//AAA..ABC
КоличествоРазрядов=СтрДлина(ПоследняяКолонка);
Для сч=1 По КоличествоРазрядов Цикл
Сравнивать=сч=КоличествоРазрядов;
рез= ЗаписатьКолонки(Колонки,»»,1,сч,Сравнивать,ПоследняяКолонка);
Если Сравнивать и рез Тогда
возврат;
КонецЕсли;
КонецЦикла;
КонецПроцедуры
11 — 08.11.16 — 23:05
Пока правильного ответа нет. Если не считать (10), так как он громоздкий.
12 — 08.11.16 — 23:47
лТЗн.Колонки.Получить(Индекс).Имя?
13 — 09.11.16 — 00:08
http://stackoverflow.com/questions/181596/how-to-convert-a-column-number-eg-127-into-an-excel-column-eg-aa
private string GetExcelColumnName(int columnNumber)
{
int dividend = columnNumber;
string columnName = String.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend — 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
dividend = (int)((dividend — modulo) / 26);
}
return columnName;
}
14 — 09.11.16 — 04:09
(13) Нагуглил. И все равно громоздко, хотя и правильно. Но у меня короче получилось
15 — 09.11.16 — 05:15
А переключит нумерацию столбов в экселе почему не хочешь?
16 — 09.11.16 — 06:30
Зная что есть ограничение на кол-во столбцов в екселе можно в одну строчку записать, но науя?
17 — 09.11.16 — 06:38
(0)А зачем? есксель и цифры прекрасно понимает.Да они наглядне
18 — 09.11.16 — 08:16
(16) Ограничение столбцов в последних версиях Excel — 16384. Точно одной строкой получится?
19 — 09.11.16 — 08:25
(18) угу всего то максимум 3 буковки
20 — 09.11.16 — 09:51
(0) СТОЛБЕЦ
См. также
Возвращает номер столбца по заданной ссылке.
Синтаксис
СТОЛБЕЦ(ссылка)
Ссылка — это ячейка или интервал ячеек, для которых определяется номер столбца.
Если ссылка опущена, то предполагается, что это ссылка на ячейку, в которой находится сама функция СТОЛБЕЦ.
Если ссылка является интервалом ячеек, и если функция СТОЛБЕЦ введена как горизонтальный массив, то функция СТОЛБЕЦ возвращает номера столбцов в ссылке в виде горизонтального массива.
Ссылка не может ссылаться на несколько областей.
Пример
Чтобы этот пример проще было понять, скопируйте его на пустой лист.
Показать Инструкции
Создайте пустую книгу или лист.
Выделите пример в разделе справки. Не выделяйте заголовок строки или столбца.
Выделение примера в справке.
Выделение примера в справке.
Нажмите сочетание клавиш CTRL+C
На листе выделите ячейку A1 и нажмите сочетание клавиш CTRL+V.
Чтобы переключиться между просмотром результатов и просмотром формул, возвращающих эти результаты, нажмите сочетание клавиш CTRL+` (апостроф) или в меню Сервис укажите на пункт Зависимости формул и выберите режим Режим проверки формул.
1
2
3
A B
Формула Описание (результат)
=СТОЛБЕЦ() Столбец в котором отображается формула (1)
=СТОЛБЕЦ(A10) Столбец ссылки (1)
21 — 09.11.16 — 17:35
(20) Чувак!
Ну все молодцы. Кроме некоторых. Темку можно закрыть
22 — 09.11.16 — 17:38
фигня какая.
давайте-ка решим здачу красиво БЕЗ ЭКСЕЛЯ
Garykom
23 — 09.11.16 — 17:43
(21) «Мариуполь, Европа»