awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
364 stars 79 forks source link

feature request: get excel column name from integer index #461

Closed markomi closed 5 years ago

markomi commented 5 years ago

Hi, I would need a function that would allow me to convert an integer index to a standard excel column name. The needed function would do the reverse of the existing convertFromExcelRef(). This functionality would be useful when constructing formulas / rules for conditional formatting.

input of the needed function: integer column index output of the needed function: excel column name

If I'm not mistaken, you already implement a similar functionality in convert_to_excel_ref (in file: openxlsx/helper_functions.cpp). I have not found a corresponding R function. Would you be able to implement such a function in R as part of openxlsx?

Thanks for your help! M.

AndrewZaremba commented 5 years ago

If I understand the question correctly, believe this exists as int2col(x).

For example

Inputs:

int2col(1)
x = 10
int2col(x)
y = 5
int2col(x-y)

Outputs:

"A"
"J"
"E"
markomi commented 5 years ago

Dear Andrew, you are absolutely right. Thanks for your support and sorry for having missed this information in the package documentation. I will close this issue.