I generate a SpreadsheetML file for MS Excel in my C# project. This worked since some changes yesterday. Now I have issues opening it. It comes up with the error:
XML PARSE ERROR: Null or missing attribute value
Error occurs at or below this element stack:
I already narrowed it down to a single table with the issue, but it has 7000+ rows with around 20 columns. When I export a single line it opens fine, so apparently not every line has the issue.
Now I'm looking for advice on how to find the issue as Excel does not provide a line number (I HATE that!).
Anybody knows a tool or good method to validate a SpreadsheetML file?
Related
so let me tell you first that im a first year programmer so dont expect much ;)
This school year is different to me. I am doing a intership at a company. I have a got a assignement but i dont have a clue how to start. My assignement is 'The user fills in a excel template. That template must be imported to a database using c# asp.net' i never worked with asp and a little with c#.
I have problems with :
1. opening a file stream with asp.net (So i can pick a file)
2. Reading the excel file
3 importing it to a db
sorry if something is unclear. Please ask.
kind regards
My windows forms application uses Novacode DocX to write a document from a template. The Novacode portion of the project works perfect and the file saves. The issue is that when I load the document the field/s (Table Of Contents) are not updated when the Novacode portion adds headings and such.
I could, and did, write a macro to update fields on open. This would solve the problem, but not everyone that will use my application will have this macro. I can't save the file as a .docm file with the macro attached for various reasons (assume file must be ".docx").
What I've found is that the Microsoft.office.interop.Word assembly will allow me to call "Fields.Update". My understanding is this will do the trick, but I can't block users that don't have word installed from running my application. My understanding is that if I am "Using Microsoft.Office.Interop.Word", or have it in my references that the application won't run if someone doesn't have word.
So I have code that checks if word is installed. If I run this, and it is installed, can I then use "Late Binding" to run interop code? Other related questions, have replies that point to "NetOffice" as a way to run interop without checking if word is installed.
I'm trying to make this as comprehensive as possible with my research. My question is very similar to this one "
how do I easily test the case where my C# application can't find an external assembly?". I would hope this issue can soon be solved for everyone, but I'm not sure it will be.
Side note, if anyone knows a way to update the fields, or even just the existing TOC, of a word document that is saved in the ".docx" format without having word installed that would be awesome to know, and would circumvent my whole issue. Although I would still like to know the answer to the interop question.
Also this is my first real question on StackOverflow, if you have tags to suggest please do so along with your answer. If you have feedback on how I ask my question, I will accept that too, but please don't close/delete the question without any answers. I linked to questions that are similar, but those questions have not gotten responses in a while. I believe I have done everything according to the rules.
This is more of an answer to your "if anyone knows a way to update the fields, or even just the existing TOC, of a word document that is saved in the ".docx" format without having word installed" question, but you might want to look in to the Open XML SDK for Office.
This will let you modify .docx files without having any dependency on having Word installed.
I found this tutorial which I think is doing almost exactly what you are wanting do do using the Open XML SDK.
Many things to say, but I think I found my answers
The main question was if I add the reference to "Microsoft.Office.Interop.Word" and the client running the application does not have word, where will the application fail? My understanding now, is that it will not fail on launch if the client does not have word. It will, however, fail when the code that uses the "Office.Interop.Word" is reached.
The way to prevent this, is a simple registry check method. I used a variation of This method to check the registry. Then before any of my code that uses the "Office.Interop.Word" code is run, I check if the client has word in the registry. If they don't have word, I take the proper notification actions for my application. I also surrounded the "Office.Interop.Word" code in a "try catch" exception block as a double safe measure. In my code the exception would mean word is not installed. A variation of the code using "Office.Interop.Word" I used to update fields can be found here.
Novacode DocX can support Docm files if you change the code yourself. I did not want to, and didn't use a docm file. Docm files have security warnings associated to them when emailed. So an auto updating macro is out of the question.
-Octopus Emoji is Celebrating
I have a crystal reports rpt file being called from C# code. Report works as expected from Designer within Studio 2010. Same report ignores Selection Criteria when called from C#, but ONLY when including a certain table's field in the criteria.
Current Criteria Example :
date({transaction.transaction_date}) in {?FromTo} and
{user_branch.branch_id} = 1
{?FromTo} is a date range parameter which works perfectly
When I remove the branch_id section, the {?FromTo} date parameter is checked correctly and the data returns as expected. BUT, as soon as I include the branch_id field, ALL the data is returned, which does not make sense at all.
Running this exact same report via the designer, works correctly... The problem occurs when running via C# SDK code.
Any help with this will be GREATLY appreciated
Already Tried
Recreate Entire Report from Scratch bit by bit, table by table. This works up to a point where I start adding more fields to the report itself, no one in particular, then the problem starts up again... So obviously, I start back tracing my steps until the entire report is empty again, but the problem persists, like the file is now "broken"
No similar issues in google... No where in my code is a line emptying the selection criteria during code... My other reports not accessing that table works fine.
Currently using version 13.0.1 of the CR Runtime. Tried to upgrade to 13.0.2, still didn't work
Ran the exact same SQL that the report generated directly against the database. That works as expected.
Try changing your criteria to:
(date({transaction.transaction_date}) in {?FromTo}) and
{user_branch.branch_id} = 1
Adding the date({transaction.transaction_date}) in {?FromTo} line inside a (). I'm not just sure.
After many head-aches this week, I finally found the problem... This looks like a bug in the SDK itself though, but to solve the problem, just make sure that the field giving the problem mentioned above is contained in the detail section of the report.
i.e. I added my branch_id field to the detail section of the report and suppressed it. It works by suppressing the section as well, just as long as the field is contained there.
I tested this on all my other reports with the same problem and it worked.
i see the following squiggly
What is this indicating ? I am trying to load a dataset through this XSD and there i believe since the imports are not getting resolved this is causing me a lot of trouble ?
Also the larger problem i have is that i have a bunch XSD Schemas which i need to convert into JSON equivalent.They have dependent xsd:import statements , what would be the best way of going about this in .net.
I solved this by going into the Security tab and selecting the suggested radio button "This is a full trust application". i used the following reference
http://social.msdn.microsoft.com/forums/en-US/asmxandxml/thread/b1db5b9f-50a4-4a21-aba1-afeb30957efd
Afternoon Developers,
I have a problem that's beginning to get on my wick. I have looked through google and Crystal Reports help and am still stuck for a solution.
We have created an XSD complete with full information about data-types and the like.
A report has been created that is linked to this XSD (using a c# class generated using Microsoft's xsd.exe SDK) and uses the field information to fill the report.
From c# we are instantiating this report and populating it with an XML file that conforms to this XSD and has been validated against it.
Now the problem is that although everything validates without errors (Crystal formulas etc) and compiles fine, when we run the application and attempt to populate the Crystal Report the Report seems to loose all knowledge of the data-typing.
Formulas such as
if ({LetProperty.lp_buildings_selected} = true) then
"Standard Cover With Accidental Damage Cover"
else
"Standard Cover";
come back with "A string is required here." error. This formula should run fine as the field referenced is a Boolean Data-Type, Crystal Reports knows this in design time.
To get it to work we have been needed to cast the field ToText and compare it to 'true'.
This is a simple work around but we will be creating many reports and don't want to twist code that should work into 'Fudged' messy code that will work.
Can anybody tell me if I am missing something glaringly obvious or if there is something that we need to set as this is confusing us immensely!
Many Thanks all.
Right,
I just wanted to let anyone know how we solved this if anyone ever gets stuck in the same situation.
What we needed to do was before populating the created dataset from the Xml file (to pass to the Report) we read the Xsd into the Dataset so that it was then strong typed and contained all the Data-typing information also.
I don't know why crystal doesn't keep all the Data-Type information that was assigned to it when we created it and linked it to the Xsd but this is how we got around that.
Is LetProperty.lp_buildings_selected set to anything besides "true" or "false" in the XML document (perhaps empty string)? If so this may be the reason that Crystal Reports is trying to use it as a string.
I believe the generated XSD is probably set up by the prevent that, but thought I'd throw it out there anyway.
Is the problem just that you need to include the schema in each XML file? Doing this will have the full type information sent to Crystal as you tell it the XML file is the DataSource. I think I had a problem like you mentioned when I did not include the XSD in the header of the XML file.