Solved

Can use BOM and SEP at the same time

Posted on 2014-02-24
4
466 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 40
COPY from excel to notepad 3 35
ADD New Entries 7 16
java jdbc batch example 8 21
Companies keep a much closer eye on costs today, so changing to new Technology – Microsoft Office 365 is the smartest move to take.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

910 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

22 Experts available now in Live!

Get 1:1 Help Now