You cannot write directly to an *.xls file and expect Excel to read it because *.xls files are not plain text files -- they contain a lot of formatting information that is readable only by Excel program.

The easiest way to do it is to creates *.csv files which Excel can import. Fieids (cells) are commma or sometimes tab separated, with CR/LF between each row. Using your example you might write it like this: Text should be surrounded with quotes (see first example below)

myfile << "\"Hello World\"," <<  nums[1] << "," <<  nums[2] << ","  nums[3] << "\n";

or
myfile << nums[1] << "\t" <<  nums[2] << "\t"  nums[3] << "\n";

Above thing is correct to write in csv but I am facing one problem to write it in csv as html editor code cannot be write as csv as it generates error on csv file writing.Due to this the only way is to write an excel file as data in html format can also be write.

Here in writing excel file I have an script which I used in writing it but while reading it using another script for excel it generates an error as mentioned below:-

"The filename shipaccountactivity1.xls is not readable"

Can u plz help me in above case as how can I write it so that it can easily be readable.......

Thanks in advance.....

Do you mean you are using an html editor to write the csv file? Then why is this question in the C board?

No sir,I m using php script but I m writing excel with html content as I have one field with product description.

Do you mean you are using an html editor to write the csv file? Then why is this question in the C board?

It doesn't matter whether it is php or c post.Thing is that html code cannot be write on an csv and that's y only excel file will be written in such case and I have done it very neately.I am just going through concept and not on language........

So much thanx........

Python has a csv module, but why has this thread been bumped into the Python forum?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.