Problem with XLS files read and write

3 views (last 30 days)
Maurizio on 7 Dec 2011
Dear All, I have a single file with a table of 8 column and 200 raw. I would like to create a function that open the XLS file and create 200 XLS files each one with the 8 value of each raw. Can somebody help me please? thanks a lot

Answers (1)

the cyclist
the cyclist on 7 Dec 2011
Have you tried the xlswrite() and xlsread() functions?
EDIT in response to comment:
You provided no detail on what you have tried, or where you are stuck. Here is the general approach I would take:
-- Use xlsread() to read the origin file into a variable
-- Use a for loop that
  1. extracts each row of that variable
  2. creates a unique filename for each row
  3. writes that row to file using xlswrite()
Maybe you could take that approach, and see if you get stuck anywhere. If you do, then post your code and your specific question about where you are stuck.
the cyclist
the cyclist on 7 Dec 2011
all(1,:) is the first row of the cell array, so it will be a 1xN cell array. You could try to do xlswrite{'fn',num2str(k),'.xls',all(1,:),'a1:u1'};
I'm not sure if xlswrite() works like that, and I cannot test it here.
If it is acceptable for you to have CSV files instead of XLS files as output, you could use the File Exchange function cellwrite(), available here:

Sign in to comment.


Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!