Extracting the whole column from excel file and putting it in a new excel file?

1 回表示 (過去 30 日間)
Kratos
Kratos 2015 年 3 月 1 日
コメント済み: Kratos 2015 年 3 月 2 日
Hello I have excel file that contains the things that I need and things that I don't.
text1.xls
Jshgfy Kashs Klaksh Item Khabsd Hsgbana Quantity
1 2 4 1 4 4 1
1 3 4 24 4 2 3
2 2 3 2 1 1 1
Things that I need are the item and quantity column. This is what I tried.
fh = xlswrite('texxt.xls'); % created a new file
[num text raw] = xlsread ['text1.xls];
I took raw and did strcmp(raw, item) to find the position of item on the xls file but I got an error. How do I find the position of item and quantity and extract the whole column and put in the new file?
Thank you.
  2 件のコメント
per isakson
per isakson 2015 年 3 月 1 日
編集済み: per isakson 2015 年 3 月 1 日
xlsread['text1.xls]; rather than xlsread('text1.xls'); is that a typing mistake? Use copy&paste!
What exactly did you try and what error message did you get?
Kratos
Kratos 2015 年 3 月 1 日
I did write xlsread('text1.xls'); after typing this I got num text and raw. After this I tried
t = {'item'}
strfind(raw, t)
to find if the first row had item. It gave me an error saying
Error using cell/strfind(line32)
if any of the input argument are cell array, the first must be a cell array of strings and the second must be a character of array.

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

採用された回答

Image Analyst
Image Analyst 2015 年 3 月 1 日
Do you not know in advance what column number 'item' may be in? Use ismember() to find the column number if you can't use a known, predetermined column number.
  4 件のコメント
Image Analyst
Image Analyst 2015 年 3 月 2 日
Try this:
ca = {'Jshgfy', 'Kashs', 'Klaksh', 'Item', 'Khabsd', 'Hsgbana', 'Quantity'}
[ia, ib] = ismember(ca, {'Item'})
letter = find(ia) + 'A' - 1
cellReference = sprintf('%c:%c', letter, letter)
Kratos
Kratos 2015 年 3 月 2 日
Thank you.

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

その他の回答 (0 件)

カテゴリ

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