Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
xlswrite command

Subject: xlswrite command

From: Nilesh Goel

Date: 29 May, 2011 10:05:05

Message: 1 of 5

Hi,

I am using the xlswrite command as follows:-

s = xlswrite ('name.xls',matrix_name,sheet_name,'A2')

before using xlswrite command I am using xlsfinfo command to get the sheet names of my original excel and I got that properly in an one dimensional array.

[typ, desc, fmt] = xlsfinfo('input_file.xlsx');

Now I want to insert the sheet name that I got from the xlsfinfo command in desc array. My input_file.xls contain 30 sheets and that is the size of desc.
Also I need to write all the 30 sheets data after processing it one by one using the simple for loop.

Please help me out how I can use xlswrite command for inputting the sheet name from
desc array.

Thanks

Subject: xlswrite command

From: Wayne King

Date: 29 May, 2011 10:57:02

Message: 2 of 5

"Nilesh Goel" wrote in message <irt5oh$f38$1@newscl01ah.mathworks.com>...
> Hi,
>
> I am using the xlswrite command as follows:-
>
> s = xlswrite ('name.xls',matrix_name,sheet_name,'A2')
>
> before using xlswrite command I am using xlsfinfo command to get the sheet names of my original excel and I got that properly in an one dimensional array.
>
> [typ, desc, fmt] = xlsfinfo('input_file.xlsx');
>
> Now I want to insert the sheet name that I got from the xlsfinfo command in desc array. My input_file.xls contain 30 sheets and that is the size of desc.
> Also I need to write all the 30 sheets data after processing it one by one using the simple for loop.
>
> Please help me out how I can use xlswrite command for inputting the sheet name from
> desc array.
>
> Thanks

Hi Nilesh, desc should be a cell array. So you can do this:

% write 4 values to range B1:B4 on the 2nd sheet
[typ,desc,fmt] = xlsfinfo('input_file.xlsx');
data = randn(4,1);
 xlswrite('input_file.xlsx',data,desc{2},'B1:B4');

Wayne

Subject: xlswrite command

From: Nilesh Goel

Date: 29 May, 2011 11:25:04

Message: 3 of 5

"Wayne King" <wmkingty@gmail.com> wrote in message <irt8pu$lv6$1@newscl01ah.mathworks.com>...
> "Nilesh Goel" wrote in message <irt5oh$f38$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I am using the xlswrite command as follows:-
> >
> > s = xlswrite ('name.xls',matrix_name,sheet_name,'A2')
> >
> > before using xlswrite command I am using xlsfinfo command to get the sheet names of my original excel and I got that properly in an one dimensional array.
> >
> > [typ, desc, fmt] = xlsfinfo('input_file.xlsx');
> >
> > Now I want to insert the sheet name that I got from the xlsfinfo command in desc array. My input_file.xls contain 30 sheets and that is the size of desc.
> > Also I need to write all the 30 sheets data after processing it one by one using the simple for loop.
> >
> > Please help me out how I can use xlswrite command for inputting the sheet name from
> > desc array.
> >
> > Thanks
>
> Hi Nilesh, desc should be a cell array. So you can do this:
>
> % write 4 values to range B1:B4 on the 2nd sheet
> [typ,desc,fmt] = xlsfinfo('input_file.xlsx');
> data = randn(4,1);
> xlswrite('input_file.xlsx',data,desc{2},'B1:B4');
>
> Wayne


Thanks wayne, but this is not solving my problem. the error msg shown is

??? Error using ==> xlswrite at 156
Sheet argument must be a string or a whole number greater than 0.

my xlswrite command is :-
xlswrite ('name.xls',matrix_name,desc(2),'A2')

Please help

Thanks

Subject: xlswrite command

From: Wayne King

Date: 29 May, 2011 11:44:04

Message: 4 of 5

"Nilesh Goel" wrote in message <irtaeg$pio$1@newscl01ah.mathworks.com>...
> "Wayne King" <wmkingty@gmail.com> wrote in message <irt8pu$lv6$1@newscl01ah.mathworks.com>...
> > "Nilesh Goel" wrote in message <irt5oh$f38$1@newscl01ah.mathworks.com>...
> > > Hi,
> > >
> > > I am using the xlswrite command as follows:-
> > >
> > > s = xlswrite ('name.xls',matrix_name,sheet_name,'A2')
> > >
> > > before using xlswrite command I am using xlsfinfo command to get the sheet names of my original excel and I got that properly in an one dimensional array.
> > >
> > > [typ, desc, fmt] = xlsfinfo('input_file.xlsx');
> > >
> > > Now I want to insert the sheet name that I got from the xlsfinfo command in desc array. My input_file.xls contain 30 sheets and that is the size of desc.
> > > Also I need to write all the 30 sheets data after processing it one by one using the simple for loop.
> > >
> > > Please help me out how I can use xlswrite command for inputting the sheet name from
> > > desc array.
> > >
> > > Thanks
> >
> > Hi Nilesh, desc should be a cell array. So you can do this:
> >
> > % write 4 values to range B1:B4 on the 2nd sheet
> > [typ,desc,fmt] = xlsfinfo('input_file.xlsx');
> > data = randn(4,1);
> > xlswrite('input_file.xlsx',data,desc{2},'B1:B4');
> >
> > Wayne
>
>
> Thanks wayne, but this is not solving my problem. the error msg shown is
>
> ??? Error using ==> xlswrite at 156
> Sheet argument must be a string or a whole number greater than 0.
>
> my xlswrite command is :-
> xlswrite ('name.xls',matrix_name,desc(2),'A2')
>
> Please help
>
> Thanks

Hi Nilesh, You did not do what I told you to do. I told you desc was a cell array and my command was:

xlswrite('input_file.xlsx',data,desc{2},'B1:B4');

You entered: desc(2)

Wayne

Subject: xlswrite command

From: Nilesh Goel

Date: 29 May, 2011 12:08:02

Message: 5 of 5

"Wayne King" <wmkingty@gmail.com> wrote in message <irtbi4$s2a$1@newscl01ah.mathworks.com>...
> "Nilesh Goel" wrote in message <irtaeg$pio$1@newscl01ah.mathworks.com>...
> > "Wayne King" <wmkingty@gmail.com> wrote in message <irt8pu$lv6$1@newscl01ah.mathworks.com>...
> > > "Nilesh Goel" wrote in message <irt5oh$f38$1@newscl01ah.mathworks.com>...
> > > > Hi,
> > > >
> > > > I am using the xlswrite command as follows:-
> > > >
> > > > s = xlswrite ('name.xls',matrix_name,sheet_name,'A2')
> > > >
> > > > before using xlswrite command I am using xlsfinfo command to get the sheet names of my original excel and I got that properly in an one dimensional array.
> > > >
> > > > [typ, desc, fmt] = xlsfinfo('input_file.xlsx');
> > > >
> > > > Now I want to insert the sheet name that I got from the xlsfinfo command in desc array. My input_file.xls contain 30 sheets and that is the size of desc.
> > > > Also I need to write all the 30 sheets data after processing it one by one using the simple for loop.
> > > >
> > > > Please help me out how I can use xlswrite command for inputting the sheet name from
> > > > desc array.
> > > >
> > > > Thanks
> > >
> > > Hi Nilesh, desc should be a cell array. So you can do this:
> > >
> > > % write 4 values to range B1:B4 on the 2nd sheet
> > > [typ,desc,fmt] = xlsfinfo('input_file.xlsx');
> > > data = randn(4,1);
> > > xlswrite('input_file.xlsx',data,desc{2},'B1:B4');
> > >
> > > Wayne
> >
> >
> > Thanks wayne, but this is not solving my problem. the error msg shown is
> >
> > ??? Error using ==> xlswrite at 156
> > Sheet argument must be a string or a whole number greater than 0.
> >
> > my xlswrite command is :-
> > xlswrite ('name.xls',matrix_name,desc(2),'A2')
> >
> > Please help
> >
> > Thanks
>
> Hi Nilesh, You did not do what I told you to do. I told you desc was a cell array and my command was:
>
> xlswrite('input_file.xlsx',data,desc{2},'B1:B4');
>
> You entered: desc(2)
>
> Wayne

Ohh sorry for my typo mistake in program. It is working fine now.

Thanks a lot Wayne

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us