Solved

Can use BOM and SEP at the same time

Posted on 2014-02-24
4
459 Views
Last Modified: 2014-03-03
We need to export a file in csv formatted file from java that contains foreign language characters.  We can do this by putting the BOM information on the first line but we also need to have the sep=, on the first line as in Europe their machines default to a semicolon as the separator.  (This is a customer facing application and we can't have them change the separator in windows)

It seems that you can't do both at the same time.  If we use the BOM it put all the columns in the first column and if we use sep= it separates them out but the language is all garbage.

UTF8_BOM = "\uFEFF";
sep=,
0
Comment
Question by:Lynnifer
4 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39893998
@Lynnifer

Is this question related to importing the resulting CSV files into something? And is that something MS Excel?

The rest of this post assumes the above to be correct...

It appears that this is something that others have encountered but seems to just be "not possible" in Excel. Refer to these forum posts...

http://social.microsoft.com/Forums/en-US/33cca906-e279-4714-a8af-eb0e02593e24/open-utf8-csv-file-with-sep-loose-encoding?forum=Offtopic
http://social.msdn.microsoft.com/Forums/office/en-US/ed67b453-ec8b-4384-9833-b51835a720af/csv-file-encoding-in-excel-2007?forum=exceldev

Is generating a different format file a possible solution? For example, if you generate an XML file in a (fairly basic) format like the below, you won't have any separator issues and XML supports UTF-8 with no problems.

Book1.xml
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
 <Worksheet ss:Name="Sheet1">
  <Table>
   <Row>
    <Cell><Data ss:Type="Number">1</Data></Cell>
    <Cell><Data ss:Type="Number">2</Data></Cell>
    <Cell><Data ss:Type="Number">3</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">Þ§</Data></Cell>
    <Cell><Data ss:Type="DateTime">2014-02-28T00:00:00.000</Data></Cell>
    <Cell><Data ss:Type="String">BLAH</Data></Cell>
   </Row>
  </Table>
 </Worksheet>
</Workbook>

Open in new window

It will load into Excel. It did using Excel2010 on my machine, but I'm sure that this would be fairly compatible with most recent versions. My win7 PC was able to tell that this .xml file had special Excel content in it and so it opens directly from an Explorer window.

You could also investigate the above XML format more deeply and do more things than you can with a simple CSV, ie. such as set cell styles, column widths, etc, etc.
0
 

Author Comment

by:Lynnifer
ID: 39900450
yes, we need to import it into Excel, sorry I didn't make that clear.  I think we came to the same solution as you.  I will go over your alternatives with my team mates and see if any of them are an option.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now