# How to directly specify datatype when reading from excel? Matrix{Any} to Vector{Int64}

**URL:** <https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853>\
**Category:** General Usage\
**Tags:** question, type, excel\
**Created:** [October 17, 2022, 2:22pm UTC](https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853 "2022-10-17T14:22:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_comen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_comen/32/33609_2.png) [@Mike\_comen](https://discourse.julialang.org/u/Mike_comen)\
**Post date:** [October 17, 2022, 2:22pm UTC](https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853/1 "2022-10-17T14:22:52Z")

</div>

I’d like to have some coulmns of an excel sheet in Julia in a `Vector{Int64}` format. However, it gives me ` Matrix{Any}`.

My try:

```julia
xf = XLSX.readxlsx(`"C:/Data/sales.xlsx"`)
A = xf["sheet1!A2:A100"])
A_vec = vec(A)

```

This return ` Vector{Any}`. How to get ` Vector{Int64}`?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 17, 2022, 2:48pm UTC](https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853/2 "2022-10-17T14:48:12Z")

</div>

As per the docs, this is what the `infer_eltypes` kwarg is for:

[https://felipenoris.github.io/XLSX.jl/stable/api/#XLSX.readtable](https://felipenoris.github.io/XLSX.jl/stable/api/#XLSX.readtable)

---

<div class="post-metadata">

**Author:** ![Mike\_comen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_comen/32/33609_2.png) [@Mike\_comen](https://discourse.julialang.org/u/Mike_comen)\
**Post date:** [October 18, 2022, 9:39pm UTC](https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853/3 "2022-10-18T21:39:49Z")

</div>

But didn’t set `infer_eltypes` neither to `true` nor `false`

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [October 18, 2022, 9:48pm UTC](https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853/4 "2022-10-18T21:48:29Z")

</div>

> But didn’t set `infer_eltypes` neither to `true` nor `false`

If you did not set it then you read with the default value, which is false.

Maybe the old trick of using identity?

```julia
julia> a = Any[1, 2, 3, 4]
4-element Vector{Any}:
 1
 2
 3
 4

julia> identity.(a)
4-element Vector{Int64}:
 1
 2
 3
 4

```

But, why cannot you read again but setting the keyword argument?

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [October 18, 2022, 9:51pm UTC](https://discourse.julialang.org/t/how-to-directly-specify-datatype-when-reading-from-excel-matrix-any-to-vector-int64/88853/5 "2022-10-18T21:51:45Z")

</div>

> [@Mike\_comen](#):
>
> But didn’t set `infer_eltypes` neither to `true` nor `false`

The docs page says:

> [@https://felipenoris.github.io/XLSX.jl/stable/api/#XLSX.readtable](#):
>
> The default value is `infer_eltypes=false`.
