C # tips for writing plain text in an Excel file format

Source: Internet
Author: User
Excel supports many formats (DBF, TXT ...).
If possible, no one wants to use Excel DLL to open the application development method.
Text separated by commas, spaces, and Tab keys can be opened in Excel.
However, I used streamwriter (C #2.0, vs2005) to write files several times, separated by special symbols, and saved as xls, which can only be opened with notepad. Chinese characters are garbled in Excel.
After a lot of analysis, we found that the following encoding is different when opened with notepad. One is ASCII and the other is UTF-8. We suspect there is a problem here.
C # The default encoding is UTF-8 when no constructor parameter is added. However, other files are in ASCII format.
Therefore, encoding. ASCII is added to the streamwriter constructor and opened in notepad and excel ?? .
Try encoding. Default again.
Let's talk about it.
But it is still unclear the specific underlying cause: Default, should be ASCII. Cannot I directly set it?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.