I'm trying to write a character in Excel using xlswrite but I am unable to do so.
Show older comments
the character is
a=' ,OK| ,g'
when i use xlswrite(file,a,sheet,range), the function writes a but with spaces. ie
, O K | , g
Each alphabet is in a different cell.
I want the entire string to come in a single cell. I used a variant xlswrite(file,{a},sheet,range) and the excel file doesn't change.
Please someone help.
Edit: I am executing these through command window:
a=NPV_run{1}
NPV_run is a 72x1 cell whose first element is ' ,OK| ,g'. Note this element is not the same as 'blank,OK|blank,g'. I compared the two strings and the two blank spaces correspond to a mismatch between the two strings.
I then used xlswrite(filename,a,sheet,range) and the result is blank , O K | blank , g each in a different cell. I also tried to use xlswrite(filename,{a},sheet,range), but in this case nothing is written and the cell remains blank.
Hope this was clear enough.
10 Comments
Walter Roberson
on 24 Apr 2013
Is it warning you about "Basic mode" ? Are you running on MS Windows with Excel installed, or are you running on OS-X or Linux, or are you running on MS Windows but without Excel installed ?
S
on 24 Apr 2013
S
on 25 Apr 2013
per isakson
on 25 Apr 2013
The value of file is that an absolute filespec?
Jan
on 25 Apr 2013
@S: Please post the full command, such that we can try to reproduce the problem. Currently you only rephrase as text, what you intented to do, but if there is an error in your code, it will not be revealed then.
Image Analyst
on 25 Apr 2013
Edited: Image Analyst
on 25 Apr 2013
S, yes I understand, but I don't think you understand about cells. Please read the FAQ for a good description of them: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
So when you said a = NPV_run{1}, you're taking the contents of that cell, not the cell itself. And as I said in my answer below, you must pass xlswrite a cell, not a string or else you get the problem you are seeing. To get the cell itself, you'd do a = NPV_run(1), with parentheses, not braces. Again, read the FAQ and then run the code in my answer below, and I think you'll understand more and be very happy.
S
on 25 Apr 2013
per isakson
on 25 Apr 2013
Edited: per isakson
on 25 Apr 2013
Is there a remote possibility that you have more than one excel-file with the same name, i.e. writing to one and checking the another?
S
on 25 Apr 2013
Image Analyst
on 25 Apr 2013
That has nothing to do with it. It's because it's a string, not a cell.
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets 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!