StimVinsh / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

error message every time i open the generated .docx #119

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.

What is the expected output? What do you see instead?
i get this message dialogue every time i open a  generated word document:
"Unable to open Open XML file FILENAME.DOCX . Problems were detected in the 
content"
 and then this :
"Word found unreadable content in FILENAME.DOCX. Do you want to recover the 
contents of this document? If you trust the source of this"

but affted i get the write values that it's supposed to give. It's just 
annoying those dialogues. 
What version of the product are you using? On what operating system?

0.9.7 on windows 7

Please provide any additional information below.

I'm still trying basic things just like in the examples :

Project project = new Project(a.getOrganismeAudite().getNom());     
context.put( "aeroport", project );
project = new Project(a.getDate());                                 
context.put( "dateaudit", project );
project = new Project(a.getOrganismeAudite().getVille());           
context.put("villeorganismeaudite", project);
project = new Project(code);                                        
context.put("code", project);
project = new Project(dateFormat.format(date));                     
context.put("datejour", project);
project = new Project(nbrecart);                                    
context.put("nbrecart", project);
project = new Project(nbrecar3b);                                   
context.put("nbrecar3b", project);

Original issue reported on code.google.com by nourelho...@gmail.com on 11 Jun 2012 at 11:06

GoogleCodeExporter commented 8 years ago
Hi,

I'm sorry but I can do nothing with your info.
Could you attach your docx + java code (main+pojo) please.

Many thank's

Regards Angelo

Original comment by angelo.z...@gmail.com on 11 Jun 2012 at 11:14

GoogleCodeExporter commented 8 years ago
yes ;), thnak you and here is the exact function that i'm calling for 
generating the docx

public void genererrapport(){
        //int idaudit=getId();
        //String organismeaudite = getOrganismeAudite().getNom();
        Audit a = new Audit();
        a=resp.findById(id);

           try
            {
                InputStream in = new FileInputStream( "C:\\Users\\noor\\Desktop\\rapport.docx" );
                IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity );

                // 2) Create context Java model  
                String code="cooooode",datejour="28/05/2012",nbrecart="7",nbrecar3b="2",nbrecar3a="2",nbrecar2="2",nbrecar1="1";
                DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyyd");
                Date date = new Date();

                IContext context = report.createContext();

                Project project = new Project(a.getOrganismeAudite().getNom());     context.put( "aeroport", project );
                project = new Project(a.getDate());                                 context.put( "dateaudit", project );
                project = new Project(a.getOrganismeAudite().getVille());           context.put("villeorganismeaudite", project);
                project = new Project(code);                                        context.put("code", project);
                project = new Project(dateFormat.format(date));                     context.put("datejour", project);
                project = new Project(nbrecart);                                    context.put("nbrecart", project);
                project = new Project(nbrecar3b);                                   context.put("nbrecar3b", project);
                project = new Project(nbrecar3a);                                   context.put("nbrecar3a", project);
                project = new Project(nbrecar2);                                    context.put("nbrecar2", project);
                project = new Project(nbrecar1);                                    context.put("nbrecar1", project);

                // 2) Create fields metadata to manage lazy loop (#forech velocity)
                // for table row.

                // 3) Create context Java model

                FieldsMetadata metadata = report.createFieldsMetadata();
                metadata.addFieldAsList( "developers.Name" );
                metadata.addFieldAsList( "developers.LastName" );
                metadata.addFieldAsList( "developers.Mail" );

                /*project = new Project( "XDocReport" );
                context.put( "project", project );*/

             //   context.put( "project", project );

                List<Developer> developers = new ArrayList<Developer>();
                developers.add( new Developer( "mmm", "mmmm", "angelo.zerr@gmail.com" ) );
                developers.add( new Developer( "Leclercq", "Pascal", "pascal.leclercq@gmail.com" ) );
                context.put( "developers", developers );

                // 3) Generate report by merging Java model with the Docx
                OutputStream out = new FileOutputStream( new File( "C:\\Users\\noor\\Desktop\\rapport_Out.docx" ) );
                report.process( context, out );
            }

            catch ( IOException e )
            {
                e.printStackTrace();
            }
            catch ( XDocReportException e )
            {
                e.printStackTrace();
            }

    }

i'v attached the .java that i'm calling, but it's calling other .java, do i 
need to send them all?? their qiut a few.

Original comment by nourelho...@gmail.com on 11 Jun 2012 at 11:21

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

please create a sample which works (every the java classes that you use) in 
order to I can run your sample with your problem.

I suggest you to test what is the problem to remove some content of your docx, 
you generate and you check if it's OK. As soon as it's OK, you readd the 
content which crashes your report. You will find what is the problem after.

It will help me alot if you can do that.

Thank's.

Regards Angelo

Original comment by angelo.z...@gmail.com on 11 Jun 2012 at 11:35

GoogleCodeExporter commented 8 years ago
will do as soon as i get the chance to work on my project:)
thanks again

Original comment by nourelho...@gmail.com on 11 Jun 2012 at 11:41

GoogleCodeExporter commented 8 years ago
I think it's because of bookmark (signet) "OLE_LINK1" and "OLE_LINK2" of your 
docx. Try to remove it from your rapport.docx. I suppose it's a bug of 
XDocReport which doesn't manage well the bookmark which must be kept.

Regards Angelo

Original comment by angelo.z...@gmail.com on 11 Jun 2012 at 2:03

GoogleCodeExporter commented 8 years ago
thanks it was the bookmars that were the cause of trouble

Original comment by nourelho...@gmail.com on 12 Jun 2012 at 3:11

GoogleCodeExporter commented 8 years ago
Yes the problem comes from with bookmark which are included into loop 
(#foreach). So it generate several bookmark with the same id, which is not 
allowed for docx.

I close this bug.

Regards Angelo

Original comment by angelo.z...@gmail.com on 22 Jun 2012 at 10:11