Solved

Txt output difference in Excel and C#

Posted on 2013-06-21
6
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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 36

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

734 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