Solved

Txt output difference in Excel and C#

Posted on 2013-06-21
6
372 Views
Last Modified: 2013-06-24
We have an old excel spreadsheet with vb macros that outputs a text/xml file. This text is used as input to another program. I've written a C#/.net web application that outputs the same text/xml file. When this file is fed to the other program, it crashes. The files are identical to the naked eye, so to speak, but there must be some formatting difference.
What am I looking for?
0
Comment
Question by:allelopath
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
gplana earned 250 total points
ID: 39267023
You can try using some tool like "WinHex" to examine the file at low level and see the differences. Also it could be an encoding character problem (maybe one is using UTF-8 and another is using Latin-1), or it could be caused by some invisible characters like spaces, tabs, line feeds, carry returns, etc...

You can also consider using a tool like windiff to compare both files.

Hope it helps.
0
 
LVL 1

Author Comment

by:allelopath
ID: 39267045
I should have been more explicit ... They look identical in a hex editor, e.g. there is 0D 0A at the end of each line. So the difference is encoding. Is there a default encoding when writing out using an excel vb macro?
0
 
LVL 15

Expert Comment

by:gplana
ID: 39267056
If they are identical in a hex editor, then the problem couldn't be the file because both files have the same content. Try to rename a file to the other and see what happens (maybe the problem is the name of the file?)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:allelopath
ID: 39267080
I take back what I said. The files are not different. The file I am generating in C# has 3 characters at the beginning:
EF BB BF      
which apparently specifies UTF-8. So I can do this with XmlWriterSettings:
this.settings.Encoding = Encoding.ASCII;

Open in new window

0
 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points
ID: 39267205
Can you post the two files?  or You can use a diff tool like beyond compare to send the differences only, especially at the top of your files.
If the contents are the same usually the difference is the encoding you need to find out the encoding of each file by using a program like Notepad++, just open the file and look for the file properties. Once you have the encoding of your original file then you just need to have the same encoding for your .net generated file.

Another option is to change the other program (that consumes your xml) to handle xml with utf-8 encoding.
0
 
LVL 1

Author Closing Comment

by:allelopath
ID: 39271643
Note that my last comment is the answer.

I tried to accept it as the answer but it looks like there is a bug in EE.
When I check the Your comment box and the Best Solution radio button for my last comment, as well as selecting the 2 posts by the experts (each defaulting to 250pts). I cannot assign points to my comment because there is no point box there and so when I submit, it won't complete saying that each accepted answer must have points.

Chrome Version 27.0.1453.116 m
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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 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

12 Experts available now in Live!

Get 1:1 Help Now