Resulting CSV Encoded as Unicode--not ANSI

I am creating a CSV file by processing a designer spreadsheet. The resulting CSV-file is encoded as Unicode, but I need the resulting file to be encoded as ANSI.

How do I change the encoding from Unicode to ANSI?

I have attached a CSV-file created with the Cells product. If you open it in Notepad and attempt to do a File-->Save As, you will notice that the Encoding is Unicode.

Thank You,

David Nowak.

Hi David,

Well, by default MS Excel saves it in unicode text. Could you give us details how to set it into ansi encoding standards using MS Excel.

Thank you.

When I create a simple Excel document and do as a Save-As CSV, the resulting file is ANSI encoded. I am using Microsoft Office Excel 2007. In fact, I tried each of the CSV-options available to me within the Save-As dialogue, and each resulted in an ANSI-encoded text file.

Thank You,

David Nowak.

Hi David,

We will get back to you soon.

Thank you.

Amjad,

By chance, have you been able to find anything on my topic? I have an application that is currently in production that creates CSV files using the designer-spreadsheet functionality in Cells. The resulting files are all encoded Unicode rather than ANSI. I really need this application to process these files automatically, rather than me having to open each CSV and resaving it with the ANSI encoding.

Thank you for all of your help.

David Nowak

Hi David,

Thanks for considering Aspose.

We will soon provide you a fix which will support to set your desired encoding.

We may add the following two methods for it:

  • Workbook.Save(Stream stream, char separator,System.Text.Encoding encoding)
  • Workbook.Save(string fileName, char separator,System.Text.Encoding encoding)

Hoping, it will suit your need.

Thank you.

Amjad,

When I coded my application, I did not pay any attention to the overloaded Workbook Save methods. The method that I have been using is:

public void Save(string, FileFormtType, SaveType, HttpResponse)

I just changed my application to use public void Save(string, char), when I am saving a CSV file specifically.

The first method saves the file encoded Unicode, but the second method saves the file encoded ANSI, which is exactly what I want.

Do you have any idea why these two overloaded methods are saving the resulting file using different encoding?

In any case, the fix that you have proposed is a nice upgrade in that the programmer will be able to choose the encoding desired, but for now, my application is working just fine and I can save the file as ANSI.

Thank You,

David Nowak.

Hi David,

Please try the attached version (4.4.1.13). We have added some relative overloaded versions (for specifying encoding) for Workbook.Save method.

e.g.., Workbook.Save(string fileName, SaveType saveType, FileFormatType fileFormatType,
HttpResponse response,System.Text.Encoding encoding) for your need.

Thank you.