hbrovell
hbrovell

Reputation: 547

Read XLSX file without specifying column and rows with XLSX pkg in Julia

I have an excel file (.xlsx) that I want to read with XLSX.jl pkg. If I use xf = XLSX.readxlsx("filename.xlsx") I get the following.

XLSXFile("filename.xlsx") containing 1 Worksheet
        sheetname size          range        
-------------------------------------------------
           Sheet1 size unknown

If I instead use XLSX.readdata("filename.xlsx", "Sheet1", "A1:J57") I get a 57x10 matrix with all the data in the excel file.

I have tried XLSX.readdata(), XLSX.openxlsx(), XLSX.readtable(), XLSX.readxlsx() But the only that works is readdataand if I specify "A1:J57 Is there a way so I don't need to specify column and rows? I have no control over the format of the sheet in the excelfile.

Upvotes: 2

Views: 584

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42264

There is a function XLSX.get_dimension as in the example below:

julia> xf = XLSX.readxlsx(raw"c:\temp\Book1.xlsx")
XLSXFile("Book1.xlsx") containing 1 Worksheet
            sheetname size          range
-------------------------------------------------
               Sheet1 16x4          A1:D16

julia> worksheet = xf[XLSX.sheetnames(xf)[1]]
16×4 XLSX.Worksheet: ["Sheet1"](A1:D16)

julia> XLSX.get_dimension(worksheet)
A1:D16

Upvotes: 1

Related Questions