Read Excel file with Matlab

2,699 ビュー (過去 30 日間)
Palumbo Piero
Palumbo Piero 2017 年 11 月 17 日
コメント済み: Paruvachi Raja 2022 年 1 月 21 日
Hello, I have an Excel file with numbers and strings. If I use the function xlsread it gives me back only the numbers. How can I read the strings?

採用された回答

Michelle Hirsch
Michelle Hirsch 2020 年 4 月 1 日
If the data in your spreadsheet is largely tabular, you'll likely be happier reading it into a table. tables allow you to mix numeric and text data in a way that's much easier to manage for most applications than a cell array.
t = readtable('myfile')
  2 件のコメント
Vinod Jha
Vinod Jha 2020 年 5 月 20 日
Hi Michelle,
Can you please suggest how I should access excel sheet of each cell contains a small image?
Michelle Hirsch
Michelle Hirsch 2020 年 5 月 20 日
I'm not sure if I know exactly what you are trying to do. My impression is that Excel doesn't actually have a concept of images in cells - images are just placed on the canvas and positioned to look like they live in cells.
Here are a couple of thoughts if you are trying to read the image data into MATLAB:
  • Take advantage of the fact that Excel files are actually ZIP files. Unzip and import the images.
For instance, I made a file with two pictures. You'll see them in the xl/media file:
>> contents = string(unzip('twopictures.xlsx'))'
contents =
14×1 string array
"[Content_Types].xml"
"_rels/.rels"
"xl/_rels/workbook.xml.rels"
"xl/workbook.xml"
"xl/drawings/drawing1.xml"
"xl/media/image1.jpeg"
"xl/styles.xml"
"xl/drawings/_rels/drawing1.xml.rels"
"xl/media/image2.jpeg"
"xl/theme/theme1.xml"
"xl/worksheets/sheet1.xml"
"xl/worksheets/_rels/sheet1.xml.rels"
"docProps/core.xml"
"docProps/app.xml"
I could then use imread to read the images, e.g.
im = imread('xl/media/image1.jpeg');
The biggest issue is I don't know how to figure out where the images were located.
  • If you are on Windows, the other approach would be to use ActiveX to connect to Excel to read the images. I'm on a Mac so I haven't tried this.

サインインしてコメントする。

その他の回答 (2 件)

KSSV
KSSV 2017 年 11 月 17 日
編集済み: KSSV 2017 年 11 月 17 日
[num,txt,raw] = xlsread('myfile') ;
num gives only numbers.
txt gives only text data.
raw gives the complete file.

Ijaz Younis
Ijaz Younis 2019 年 11 月 6 日
[num,txt,raw] = xlsread('myfile')
  1 件のコメント
Paruvachi Raja
Paruvachi Raja 2022 年 1 月 21 日
xlasread is not commended according MATHWORKS.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by