write an excel file with both string and numeric data

Hi,

i need to write a table with cols of numbers separated by cols of strings in an excel file

5 rows with Name as string, i.e.:

Name = "&"|"&"|"&"|"&"|"&";

and numbers form calculations, i.e.:

SLM1[.,1]

if i write

Fout = SLM1[.,1]~Name;

then

ret = spreadSheetWrite(Fout, "myfile.xlsx","A1");

the cols Name turns to a [5x1] of zeros...

can you please help?

thanks

laura

1 Answer



0



I don't know if it's the most efficient way to do this,  but I've used xlswritem to output the numeric columns and xlswritesa to output the columns that are strings.  I find xlsmakerange() helpful in doing this.

For the sake of the example, let's say you have calculated a numerical variable slm1[.,1] and that the strings variables are stored in a string array, slmSA, with 5 columns.

fout = "myfile.xlsx";  /* modify this for the appropriate directory";

outrow = 1 | rows(slm1); /* modify this if you want to add a header row */

outcol = 1 | 1;

outrange = xlsmakerange(outrow, outcol);

chk = xlswritem(fout, outrange, 1, "");  /* should write to col A in output file, chk = 0 if failure, 1 - if successful */

outrowSA = 1 | rows(slmSA);

outcolSA = 2 | (1+cols(slmSA));

chkSA = xlswriteSA(fout, outrange, 1, "");  /* should write strings to cols B -F, chksa = 0 if failure, 1 - if successful */

I think this code will work.

Your Answer

1 Answer

0

I don't know if it's the most efficient way to do this,  but I've used xlswritem to output the numeric columns and xlswritesa to output the columns that are strings.  I find xlsmakerange() helpful in doing this.

For the sake of the example, let's say you have calculated a numerical variable slm1[.,1] and that the strings variables are stored in a string array, slmSA, with 5 columns.

fout = "myfile.xlsx";  /* modify this for the appropriate directory";

outrow = 1 | rows(slm1); /* modify this if you want to add a header row */

outcol = 1 | 1;

outrange = xlsmakerange(outrow, outcol);

chk = xlswritem(fout, outrange, 1, "");  /* should write to col A in output file, chk = 0 if failure, 1 - if successful */

outrowSA = 1 | rows(slmSA);

outcolSA = 2 | (1+cols(slmSA));

chkSA = xlswriteSA(fout, outrange, 1, "");  /* should write strings to cols B -F, chksa = 0 if failure, 1 - if successful */

I think this code will work.


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.