# How to get in XLSX.jl a XLSX.CellRef from column and row number

**URL:** <https://discourse.julialang.org/t/how-to-get-in-xlsx-jl-a-xlsx-cellref-from-column-and-row-number/48752>\
**Category:** New to Julia\
**Tags:** package, xlsx\
**Created:** [October 21, 2020, 3:09pm UTC](https://discourse.julialang.org/t/how-to-get-in-xlsx-jl-a-xlsx-cellref-from-column-and-row-number/48752 "2020-10-21T15:09:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GerhardTotschnig](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gerhardtotschnig/32/215516_2.png) [@GerhardTotschnig](https://discourse.julialang.org/u/GerhardTotschnig)\
**Post date:** [October 21, 2020, 3:09pm UTC](https://discourse.julialang.org/t/how-to-get-in-xlsx-jl-a-xlsx-cellref-from-column-and-row-number/48752/1 "2020-10-21T15:09:29Z")

</div>

I have a Question regarding XLSX.jl:

One can insert a 2 dimensional data matrix `MA` via,

```julia
XLSX.openxlsx("my_Test.xlsx", mode="rw") do xf
    sheet = xf[1]
    sheet["C7"] = MA
end

```

but if I want to add this matrix in column 100 row 7 then I did not find out how a easy way to do it.  
One can access the content of column 100 row 7 via `sheet[100,7]`.  
But for `sheet[100,7] = MA` no method is defined.  
For inserting the matrix one needs a cell reference in the style `sheet["CO7"]`.

How can I find out what the cell reference for `sheet[100,7]` is?  
How to get in XLSX.jl a XLSX.CellRef from column and row number

Many Thanks  
Gerhard

---

<div class="post-metadata">

**Author:** ![AndiMD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andimd/32/6531_2.png) [@AndiMD](https://discourse.julialang.org/u/AndiMD)\
**Post date:** [October 21, 2020, 8:50pm UTC](https://discourse.julialang.org/t/how-to-get-in-xlsx-jl-a-xlsx-cellref-from-column-and-row-number/48752/2 "2020-10-21T20:50:49Z")

</div>

You could index using `XLSX.CellRef(100,7)`. It is unexported though, so there might be a better way.  
`sheet[XLSX.CellRef(100,7)] = MA`

---

<div class="post-metadata">

**Author:** ![felipenoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/felipenoris/32/553_2.png) [@felipenoris](https://discourse.julialang.org/u/felipenoris)\
**Post date:** [November 10, 2020, 3:07pm UTC](https://discourse.julialang.org/t/how-to-get-in-xlsx-jl-a-xlsx-cellref-from-column-and-row-number/48752/3 "2020-11-10T15:07:48Z")

</div>

`sheet[r, c] = value` should work. It is [defined](https://github.com/felipenoris/XLSX.jl/blob/68a6cf5aff00987e82afb9684a71bb732a89928c/src/write.jl#L302).

This code works.

```julia
XLSX.openxlsx(fp, mode="rw") do xf
           sheet = xf[1]
           sheet["B1"] = "new data"
           sheet[10,2] = "other data"
       end

```

Can you share the version for XLSX you’re using and the error message?

---

<div class="post-metadata">

**Author:** ![GerhardTotschnig](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gerhardtotschnig/32/215516_2.png) [@GerhardTotschnig](https://discourse.julialang.org/u/GerhardTotschnig)\
**Post date:** [November 11, 2020, 10:47am UTC](https://discourse.julialang.org/t/how-to-get-in-xlsx-jl-a-xlsx-cellref-from-column-and-row-number/48752/4 "2020-11-11T10:47:01Z")

</div>

Thank you for your reply(@ [felipenoris](https://discourse.julialang.org/u/felipenoris)). Sorry for the late reply I was out of office:  
I was asking for a way to insert a Matrix at a certain position:

```julia
A=[1 2; 3 4]
XLSX.openxlsx("my_Try.xlsx", mode="w") do xf
    sheet = xf[1]
    sheet[10,2]= A
end
ERROR: MethodError: no method matching setdata!(::XLSX.Worksheet, ::Int64, ::Int64, ::Array{Int64,2})

```

does not work. I am using XLSX v0.7.3 and Julia 1.5

sheet[“B10”]=A  
would work.  
But if I want to add a matrix or vector programmatically in some far away column this does not help.  
Thanks to @[AndiMD](https://discourse.julialang.org/u/AndiMD)  
sheet[XLSX.CellRef(10,2)]=A  
works.
