Data Transfer from .xls Files

3 posts / 0 new
Last post
Data Transfer from .xls Files

Is it possible to read the full contents of .xls files into an array, without having to name the range of cells being read (similar to how csvread can read .csv files to an array)?

We wrote a script that reads spreadsheets containing on-site weather measurements (irradiance, temperature, wind speed), and runs a simulation based on them. However, the on-site weather measurements are in .xls form, and can have a varying number of rows depending on the timeframe chosen for analysis and the measurement interval (there is one row of data per timestamp). Since we couldn't find a way to read the data directly from .xls files, we're currently opening the .xls weather measurements manually in Excel, saving as a .csv, and then running the script using csvread.

Is there a more automated way to do this- can the script read all of the data into arrays directly from the .xls file (without having to manually assign a name in Excel to the range of cells being read), or else can it automatically convert an .xls file to a .csv file?

Paul Gilman


As you note, the LK functions that work with Excel objects can only read and write to single cells xl_get(xl,'a1'); or to ranges of cells if they are named xl_get(xl,'my_range');. You probably already found the example files at the bottom of the Samples page, but here's a link for others who may not have seen it:

Perhaps you could write a script in Python or some other language to convert the Excel files to CSV before running your LK script -- there are several examples on the web.

Best regards,


Thanks you Paul Gilman

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer