Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > BIRT
BIRT Forum d'entraide sur BIRT (Business Intelligence and Reporting Tools). Avant de poster --> FAQ BIRT,Tutoriels BIRT
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 30/06/2006, 09h04   #1
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
Par défaut Exporter un rapport en xls (MSExcel)

Bonjour tout le monde,

Je génère des rapports avec le BIRT Engine (API BIRT). Donc je me sers de task, etc...
J'exporte en pdf, en html, nickel.

Je m'intérèsse maintenant au xls. Problème, BIRT, en natif, ne propose pas ça.
Je me tourne donc vers Tribix et son exportateur excel :
http://qauck.blogspot.com/
http://qauck.wordpress.com/
http://sourceforge.net/projects/tribix/

Bien que j'arrive à visualiser des rapports en xls sous Eclipse avec la fonction "preview" (cela veut donc dire que je l'ai bien installé), je n'arrive pas à générer un xls avec le Report Engine.

Quelqu'un y est-il arrivé ?
Avez-vous une solution ?

Merci
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 09h48   #2
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Si tu trouves la solution, fais moi signe s'il te plait
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h00   #3
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
lol ah ben super, j'suis pas arrivé
En fait, dans le patch pour l'ermitter Excel, on voit que RenderTask est mis à jour pour supporter les formats xls et ppt.
Le problème, c'est que le format est également "checké" par la classe "ExtensionManager", qui elle, n'est PAS patchée ... Donc, quand je mets le format xls, je me fais jeter avec un joli
Citation:
org.eclipse.birt.report.engine.api.EngineException: The output format xls is not supported.
:'(
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h10   #4
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Je pense qu'il faut que tu reprennes les sources de org.eclipse.birt.report.engine.emitter.fo ou html ou pdf (essayes d'abord avec FO) et que tu les recompiles dans un JAR nommé : org.eclipse.birt.report.engine.emitter.xls

Ou un truc approchant de ça...
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h18   #5
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
J'ai déjà ce .jar : xls-emitter.jar
dans le plugin pour faire marcher les rapports xls
C'est pour ça, logiquement j'ai toutes les cartes en main mais je n'y arrive pas
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h25   #6
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Moi j'ai pas compris ce qu'on fait avec ce qu'il y a dans patch.

Ce truc m'interesse vraiment !
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h28   #7
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
Citation:
4. Download and apply the designer/viewer/engine patch file so to make the xls plugin work correctly both in the designer and viewer. If you are building BIRT from a CVS source tree, override the soure file; if you are just using the binary BIRT sdk, replace the class files in related plugin jar. Here is the list:

org.eclipse.birt.report.designer.ui org\eclipse\birt\report\designer\ui\actions\PreviewToolbarMenuAction in plugins/org.eclipse.birt.report.designer.ui.preview_2.1.0.*.jar

org.eclipse.birt.report.viewer org\eclipse\birt\report\presentation\aggregation\layout\EngineFragment in plugins/org.eclipse.birt.report.viewer_2.1.0.*/birt/WEB-INF/lib/viewservlets.jar

(*This time we need to patch the engine too, looks it doesn't much like the extended emitters now, all other emitters than PDF will be thought as the HTML one)

org.eclipse.birt.report.engine org\eclipse\birt\report\engine\api\impl\RenderTask in plugins/org.eclipse.birt.report.engine_2.1.0.*.jar
org.eclipse.birt.report.engine org\eclipse\birt\report\engine\layout\LayoutEngineFactory in plugins/org.eclipse.birt.report.engine_2.1.0.*.jar
En fait, dans le patch, tu trouveras des .class qu'il faut copier dans les .jar cités ci-dessus.
Par exemple, dans :
plugins/org.eclipse.birt.report.engine_2.1.0.*.jar
Tu remplaces RenderTask.class par celui fournit dans le patch
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h31   #8
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Tu as fait un diff avec les anciens fichiers pour voir ce qu'il y avait en plus et en moins s'il te plait ?
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h38   #9
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
L'original :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
 
public class RenderTask extends EngineTask implements IRenderTask
{
	IReportDocument reportDoc;
	String emitterID;
	boolean bodyOnly;
 
	private InnerRender innerRender;
 
	/**
	 * @param engine
	 *            the report engine
	 * @param runnable
	 *            the report runnable object
	 * @param reportDoc
	 *            the report document instance
	 */
	public RenderTask( IReportEngine engine, IReportRunnable runnable,
			IReportDocument reportDoc )
	{
		super( engine, runnable );
 
		executionContext.setFactoryMode( false );
		executionContext.setPresentationMode( true );
 
		// open the report document
		openReportDocument( reportDoc );
 
		// load report design
		loadDesign( );
 
		innerRender = new PageRangeRender( new long[]{1, this.reportDoc.getPageCount( )} );
	}
 
	protected void openReportDocument( IReportDocument reportDoc )
	{
		this.reportDoc = reportDoc;
		executionContext.setReportDocument( reportDoc );
 
		// load the informationf rom the report document
		setParameterValues( reportDoc.getParameterValues( ) );
		usingParameterValues( );
		executionContext.registerGlobalBeans( reportDoc
				.getGlobalVariables( null ) );
	}
 
	protected void closeReportDocument( )
	{
		//the report document is shared by mutiple render task, 
		//it is open by the caller, it should be closed by the caller.
		//reportDoc.close( );
	}
 
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render(long)
	 */
	public void render( long pageNumber ) throws EngineException
	{
		setPageNumber( pageNumber );
		render( );
	}
 
	protected IContentEmitter createContentEmitter( )
			throws EngineException
	{
		String format = executionContext.getOutputFormat( );
 
		if ("html".equalsIgnoreCase( format ))
		{
			bodyOnly = false;
		}
		else
		{
			bodyOnly = true;
		}
 
		ExtensionManager extManager = ExtensionManager.getInstance( );
		boolean supported = false;
		Collection supportedFormats = extManager.getSupportedFormat( );
		Iterator iter = supportedFormats.iterator( );
		while ( iter.hasNext( ) )
		{
			String supportedFormat = (String) iter.next( );
			if ( supportedFormat != null
					&& supportedFormat.equalsIgnoreCase( format ) )
			{
				supported = true;
				break;
			}
		}
 
		if ( !supported )
		{
			log.log( Level.SEVERE,
					MessageConstants.FORMAT_NOT_SUPPORTED_EXCEPTION, format );
			throw new EngineException(
					MessageConstants.FORMAT_NOT_SUPPORTED_EXCEPTION, format );
		}
 
		IContentEmitter emitter = extManager.createEmitter( format, emitterID );
		if ( emitter == null )
		{
			log.log( Level.SEVERE, "Report engine can not create {0} emitter.", //$NON-NLS-1$
					format ); // $NON-NLS-1$
			throw new EngineException(
					MessageConstants.CANNOT_CREATE_EMITTER_EXCEPTION );
		}
 
		//the output will be paginate.
		if ( !bodyOnly )
		{
			emitter = new HTMLTableLayoutEmitter( emitter, true );
		}
 
		return emitter;
	}
 
	private void initializeContentEmitter( IContentEmitter emitter,
			IReportExecutor executor )
	{
		// create the emitter services object that is needed in the emitters.
		EngineEmitterServices services = new EngineEmitterServices( this );
 
		EngineConfig config = engine.getConfig( );
		if ( config != null )
		{
			services.setEmitterConfig( config.getEmitterConfigs( ) );
		}
		services.setRenderOption( renderOptions );
		services.setExecutor( executor );
		services.setRenderContext( appContext );
		services.setReportRunnable( runnable );
 
		// emitter is not null
		emitter.initialize( services );
	}
 
	/**
	 * @param pageNumber
	 *            the page to be rendered
	 * @throws EngineException
	 *             throws exception if there is a rendering error
	 */
	protected void doRender( long pageNumber ) throws EngineException
	{
		try
		{
			IContentEmitter emitter = createContentEmitter( );
			ReportDesignHandle reportDesign = executionContext.getDesign( );
			String format = executionContext.getOutputFormat( );
			if ( "pdf".equalsIgnoreCase( format ) ) //$NON-NLS-1$
			{
				IReportExecutor executor = new ReportPageReader(
						executionContext, pageNumber, false );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				IReportLayoutEngine layoutEngine = LayoutEngineFactory
						.createLayoutEngine( format );
				OnPageBreakLayoutPageHandle handle = new OnPageBreakLayoutPageHandle( executionContext );
				layoutEngine.setPageHandler( handle );
				startRender( );
				layoutEngine.layout( executor, emitter, false );
				closeRender( );
				executor.close( );
			}
			else
			{
				IReportExecutor executor = new ReportExecutor(
						executionContext, reportDesign, null );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				// start the render
				ReportContentLoader loader = new ReportContentLoader(
						executionContext );
				startRender( );
				loader.loadPage( pageNumber, bodyOnly, emitter );
				closeRender( );
				executor.close( );
			}
		}
		catch ( Exception ex )
		{
			log.log( Level.SEVERE,
					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$
		}
		catch ( OutOfMemoryError err )
		{
			log.log( Level.SEVERE,
					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$
			throw err;
		}
	}
 
	/**
	 * @param pageNumber
	 *            the page to be rendered
	 * @throws EngineException
	 *             throws exception if there is a rendering error
	 */
	protected void doRender( List pageSequences ) throws EngineException
	{
		if ( pageSequences.size( ) == 0 )
		{
			return;
		}
		try
		{
			// start the render
			ReportDesignHandle reportDesign = executionContext.getDesign( );
			IContentEmitter emitter = createContentEmitter( );
			String format = executionContext.getOutputFormat( );
			if ( "pdf".equalsIgnoreCase( format ) ) //$NON-NLS-1$
			{
				IReportExecutor executor = new ReportPageReader(
						executionContext, pageSequences, false );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				IReportLayoutEngine layoutEngine = LayoutEngineFactory
						.createLayoutEngine( format );
				OnPageBreakLayoutPageHandle handle = new OnPageBreakLayoutPageHandle( executionContext );
				layoutEngine.setPageHandler( handle );
				startRender( );
				layoutEngine.layout( executor, emitter, true );
				closeRender( );
				executor.close( );
			}
			else
			{
				IReportExecutor executor = new ReportExecutor(
						executionContext, reportDesign, null );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				ReportContentLoader loader = new ReportContentLoader(
						executionContext );
				startRender( );
				loader.loadPageRange( pageSequences, bodyOnly, emitter );
				closeRender( );
				executor.close( );
			}
 
 
 
		}
		catch ( Exception ex )
		{
			log.log( Level.SEVERE,
					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$
		}
		catch ( OutOfMemoryError err )
		{
			log.log( Level.SEVERE,
					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$
			throw err;
		}
	}
 
	/**
	 * @param offset
	 *            the offset of the reportlet to be rendered
	 * @throws EngineException
	 *             throws exception if there is a rendering error
	 */
	protected void doRenderReportlet( long offset ) throws OutOfMemoryError
	{
		try
		{
			if (offset != -1)
			{
				// start the render
 
				IContentEmitter emitter = createContentEmitter( );
				ReportDesignHandle reportDesign = executionContext.getDesign( );
				String format = executionContext.getOutputFormat( );
				if ( "pdf".equalsIgnoreCase( format ) ) //$NON-NLS-1$
				{
					IReportExecutor executor = new ReportletReader(
							executionContext, offset );
					executor = new LocalizedReportExecutor( executionContext,
							executor );
					executionContext.setExecutor( executor );
					initializeContentEmitter( emitter, executor );
					IReportLayoutEngine layoutEngine = LayoutEngineFactory
							.createLayoutEngine( format );
					OnPageBreakLayoutPageHandle handle = new OnPageBreakLayoutPageHandle( executionContext );
					layoutEngine.setPageHandler( handle );
					startRender( );
					layoutEngine.layout( executor, emitter, false );
					closeRender( );
					executor.close( );
				}
				else
				{
					ReportContentLoader loader = new ReportContentLoader(
							executionContext );
					IReportExecutor executor = new ReportExecutor(
							executionContext, reportDesign, null );
					executor = new LocalizedReportExecutor( executionContext,
							executor );
					executionContext.setExecutor( executor );
 
					initializeContentEmitter( emitter, executor );
					startRender( );
					loader.loadReportlet( offset, emitter );
					closeRender( );
					executor.close( );
				}
			}
		}
		catch ( Exception ex )
		{
			log.log( Level.SEVERE,
					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$
		}
		catch ( OutOfMemoryError err )
		{
			log.log( Level.SEVERE,
					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$
			throw err;
		}
	}	
 
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setEmitterID(java.lang.String)
	 */
	public void setEmitterID( String id )
	{
		this.emitterID = id;
	}
 
	/**
	 * @return the emitter ID to be used to render this report. Could be null,
	 *         in which case the engine will choose one emitter that matches the
	 *         requested output format.
	 */
	public String getEmitterID( )
	{
		return this.emitterID;
	}
 
	public void close( )
	{
		closeReportDocument( );
		super.close( );
	}
 
	public void render( String pageRange ) throws EngineException
	{
		setPageRange( pageRange );
		render( );
	}
 
	private List parsePageSequence( String pageRange, long totalPage )
	{
		ArrayList list = new ArrayList( );
		if ( null == pageRange
				|| "".equals( pageRange ) || pageRange.toUpperCase( ).indexOf( "ALL" ) >= 0 ) //$NON-NLS-1$ //$NON-NLS-2$
		{
			list.add( new long[]{1, totalPage} );
			return list;
		}
		String[] ps = pageRange.split( "," ); //$NON-NLS-1$
		for ( int i = 0; i < ps.length; i++ )
		{
			try
			{
				if ( ps[i].indexOf( "-" ) > 0 ) //$NON-NLS-1$
				{
					String[] psi = ps[i].split( "-" ); //$NON-NLS-1$
					if ( psi.length == 2 )
					{
						long start = Long.parseLong( psi[0].trim( ) );
						long end = Long.parseLong( psi[1].trim( ) );
						if ( end > start )
						{
							list.add( new long[]{Math.max( start, 1 ),
									Math.min( end, totalPage )} );
						}
					}
					else
					{
						log.log( Level.SEVERE,
								"error page number range: {0}", ps[i] ); //$NON-NLS-1$
					}
				}
				else
				{
					long number = Long.parseLong( ps[i].trim( ) );
					if ( number > 0 && number <= totalPage )
					{
						list.add( new long[]{number, number} );
					}
					else
					{
						log.log( Level.SEVERE,
								"error page number range: {0}", ps[i] ); //$NON-NLS-1$
					}
 
				}
			}
			catch ( NumberFormatException ex )
			{
				log.log( Level.SEVERE, "error page number rang:", ps[i] ); //$NON-NLS-1$
			}
		}
		return sort( list );
	}
 
	private List sort( List list )
	{
		for ( int i = 0; i < list.size( ); i++ )
		{
			long[] currentI = (long[]) list.get( i );
			int minIndex = i;
			long[] min = currentI;
			for ( int j = i + 1; j < list.size( ); j++ )
			{
				long[] currentJ = (long[]) list.get( j );
				if ( currentJ[0] < min[0] )
				{
					minIndex = j;
					min = currentJ;
				}
			}
			if ( minIndex != i )
			{
				// swap
				list.set( i, min );
				list.set( minIndex, currentI );
			}
		}
		long[] current = null;
		long[] last = null;
		ArrayList ret = new ArrayList( );
		for ( int i = 0; i < list.size( ); i++ )
		{
			current = (long[]) list.get( i );
			if ( last != null )
			{
				if ( current[1] <= last[1] )
					continue;
				if ( current[0] <= last[1] )
					current[0] = last[1];
					ret.add( current );
			}
			else
			{
				ret.add( current );
			}
			last = current;
		}
		return ret;
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render(org.eclipse.birt.report.engine.api.InstanceID)
	 */
	public void render(InstanceID iid) throws EngineException {
		setInstanceID( iid );
		render( );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render()
	 */
	public void render() throws EngineException {
		if ( renderOptions == null )
		{
			throw new EngineException(
					"Render options have to be specified to render a report." ); //$NON-NLS-1$
		}
		innerRender.render( );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render()
	 */
	public void setPageNumber( long pageNumber ) throws EngineException
	{
		long totalPage = reportDoc.getPageCount( );
		if ( pageNumber <= 0 || pageNumber > totalPage )
		{
			throw new EngineException( "Can't find page hints :{0}", new Long( //$NON-NLS-1$
					pageNumber ) );
		}
		innerRender = new PageRender( pageNumber);
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setInstanceID( InstanceID iid )
	 */
	public void setInstanceID( InstanceID iid ) throws EngineException
	{
		innerRender = new ReportletRender( iid );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setPageRange( String pageRange )
	 */
	public void setPageRange( String pageRange ) throws EngineException
	{
		innerRender = new PageRangeRender( parsePageSequence( pageRange, reportDoc.getPageCount( )) );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setBookmark( String bookmark )
	 */
	public void setBookmark( String bookmark ) throws EngineException
	{
		long pageNumber = reportDoc.getPageNumber( bookmark );
		if ( pageNumber <= 0 ) {
			throw new EngineException( "Can't find bookmark :{0}", bookmark ); //$NON-NLS-1$
		}
		innerRender = new PageRender( pageNumber );
	}
 
	public void setReportlet( String bookmark ) throws EngineException
	{
		innerRender = new ReportletRender( bookmark ); 
	}
 
	private interface InnerRender
	{
		void render() throws EngineException;
	}
 
	/**
	 * Renders a page with a page number. 
	 */
	private class PageRender implements InnerRender
	{
		private long pageNumber;
 
		public PageRender( long pageNumber )
		{
			this.pageNumber = pageNumber;
		}
 
		public void render( ) throws EngineException
		{
			RenderTask.this.doRender( pageNumber );
		}
	}
 
	/**
	 * Renders a range of pages. 
	 */
	private class PageRangeRender implements InnerRender
	{
		private List pageRange;
 
		public PageRangeRender( long[] arrayRange )
		{
			this.pageRange = new ArrayList();
			pageRange.add( arrayRange );
		}
 
		public PageRangeRender( List pageRange )
		{
			this.pageRange = pageRange;
		}
 
		public void render( ) throws EngineException
		{
			RenderTask.this.doRender( pageRange );
		}
	}
 
	private class ReportletRender implements InnerRender
	{
		private long offset;
 
		ReportletRender(InstanceID iid) throws EngineException
		{
			this.offset = reportDoc.getInstanceOffset( iid );
			if ( offset == -1 )
			{
				throw new EngineException(
					"Invalid instance id :" + iid ); //$NON-NLS-1$
			}
		}
 
		ReportletRender( String bookmark ) throws EngineException
		{
			this.offset = reportDoc.getBookmarkOffset( bookmark );
			if ( offset == -1 )
			{
				throw new EngineException(
					"Invalid bookmark :" + bookmark ); //$NON-NLS-1$
			}
		}
 
		public void render( ) throws EngineException
		{
			RenderTask.this.doRenderReportlet( offset );
		}
	}
 
	public void setInstanceID( String iid ) throws EngineException
	{
		setInstanceID( InstanceID.parse( iid ));
	}
}
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h39   #10
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
Le patché :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
 
 
public class RenderTask extends EngineTask implements IRenderTask
{
	IReportDocument reportDoc;
	String emitterID;
	boolean bodyOnly;
 
	private InnerRender innerRender;
 
	/**
	 * @param engine
	 *            the report engine
	 * @param runnable
	 *            the report runnable object
	 * @param reportDoc
	 *            the report document instance
	 */
	public RenderTask( IReportEngine engine, IReportRunnable runnable,
			IReportDocument reportDoc )
	{
		super( engine, runnable );
 
		executionContext.setFactoryMode( false );
		executionContext.setPresentationMode( true );
 
		// open the report document
		openReportDocument( reportDoc );
 
		// load report design
		loadDesign( );
 
		innerRender = new PageRangeRender( new long[]{1, this.reportDoc.getPageCount( )} );
	}
 
	protected void openReportDocument( IReportDocument reportDoc )
	{
		this.reportDoc = reportDoc;
		executionContext.setReportDocument( reportDoc );
 
		// load the informationf rom the report document
		setParameterValues( reportDoc.getParameterValues( ) );
		usingParameterValues( );
		executionContext.registerGlobalBeans( reportDoc
				.getGlobalVariables( null ) );
	}
 
	protected void closeReportDocument( )
	{
		//the report document is shared by mutiple render task, 
		//it is open by the caller, it should be closed by the caller.
		//reportDoc.close( );
	}
 
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render(long)
	 */
	public void render( long pageNumber ) throws EngineException
	{
		setPageNumber( pageNumber );
		render( );
	}
 
	protected IContentEmitter createContentEmitter( )
			throws EngineException
	{
		String format = executionContext.getOutputFormat( );
 
		if ("html".equalsIgnoreCase( format ))
		{
			bodyOnly = false;
		}
		else
		{
			bodyOnly = true;
		}
 
		ExtensionManager extManager = ExtensionManager.getInstance( );
		boolean supported = false;
		Collection supportedFormats = extManager.getSupportedFormat( );
		Iterator iter = supportedFormats.iterator( );
		while ( iter.hasNext( ) )
		{
			String supportedFormat = (String) iter.next( );
			if ( supportedFormat != null
					&& supportedFormat.equalsIgnoreCase( format ) )
			{
				supported = true;
				break;
			}
		}
 
		if ( !supported )
		{
			log.log( Level.SEVERE,
					MessageConstants.FORMAT_NOT_SUPPORTED_EXCEPTION, format );
			throw new EngineException(
					MessageConstants.FORMAT_NOT_SUPPORTED_EXCEPTION, format );
		}
 
		IContentEmitter emitter = extManager.createEmitter( format, emitterID );
		if ( emitter == null )
		{
			log.log( Level.SEVERE, "Report engine can not create {0} emitter.", //$NON-NLS-1$
					format ); // $NON-NLS-1$
			throw new EngineException(
					MessageConstants.CANNOT_CREATE_EMITTER_EXCEPTION );
		}
 
		//the output will be paginate.
		if (!bodyOnly)
		{
			emitter = new HTMLTableLayoutEmitter(emitter);
		}
 
		return emitter;
	}
 
	private void initializeContentEmitter( IContentEmitter emitter,
			IReportExecutor executor )
	{
		// create the emitter services object that is needed in the emitters.
		EngineEmitterServices services = new EngineEmitterServices( this );
 
		EngineConfig config = engine.getConfig( );
		if ( config != null )
		{
			services.setEmitterConfig( config.getEmitterConfigs( ) );
		}
		services.setRenderOption( renderOptions );
		services.setExecutor( executor );
		services.setRenderContext( appContext );
		services.setReportRunnable( runnable );
 
		// emitter is not null
		emitter.initialize( services );
	}
 
	/**
	 * @param pageNumber
	 *            the page to be rendered
	 * @throws EngineException
	 *             throws exception if there is a rendering error
	 */
	protected void doRender( long pageNumber ) throws EngineException
	{
		try
		{
			IContentEmitter emitter = createContentEmitter( );
			ReportDesignHandle reportDesign = executionContext.getDesign( );
			String format = executionContext.getOutputFormat( );
			if ( "pdf".equalsIgnoreCase( format ) || "xls".equalsIgnoreCase( format ) || "ppt".equalsIgnoreCase( format ) ) //$NON-NLS-1$
			{
				IReportExecutor executor = new ReportPageReader(
						executionContext, pageNumber, false );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				IReportLayoutEngine layoutEngine = LayoutEngineFactory
						.createLayoutEngine( format );
				startRender( );
				layoutEngine.layout( executor, emitter );
				closeRender( );
				executor.close( );
			}
			else
			{
				IReportExecutor executor = new ReportExecutor(
						executionContext, reportDesign, null );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				// start the render
				ReportContentLoader loader = new ReportContentLoader(
						executionContext );
				startRender( );
				loader.loadPage( pageNumber, bodyOnly, emitter );
				closeRender( );
				executor.close( );
			}
		}
		catch ( Exception ex )
		{
			log.log( Level.SEVERE,
					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$
		}
		catch ( OutOfMemoryError err )
		{
			log.log( Level.SEVERE,
					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$
			throw err;
		}
	}
 
	/**
	 * @param pageNumber
	 *            the page to be rendered
	 * @throws EngineException
	 *             throws exception if there is a rendering error
	 */
	protected void doRender( List pageSequences ) throws EngineException
	{
		if ( pageSequences.size( ) == 0 )
		{
			return;
		}
		try
		{
			// start the render
			ReportDesignHandle reportDesign = executionContext.getDesign( );
			IContentEmitter emitter = createContentEmitter( );
			String format = executionContext.getOutputFormat( );
			if ( "pdf".equalsIgnoreCase( format ) || "xls".equalsIgnoreCase( format ) || "ppt".equalsIgnoreCase( format ) ) //$NON-NLS-1$
			{
				IReportExecutor executor = new ReportPageReader(
						executionContext, pageSequences, false );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				IReportLayoutEngine layoutEngine = LayoutEngineFactory
						.createLayoutEngine( format );
				startRender( );
				layoutEngine.layout( executor, emitter );
				closeRender( );
				executor.close( );
			}
			else
			{
				IReportExecutor executor = new ReportExecutor(
						executionContext, reportDesign, null );
				executor = new LocalizedReportExecutor( executionContext,
						executor );
				executionContext.setExecutor( executor );
				initializeContentEmitter( emitter, executor );
				ReportContentLoader loader = new ReportContentLoader(
						executionContext );
				startRender( );
				loader.loadPageRange( pageSequences, bodyOnly, emitter );
				closeRender( );
				executor.close( );
			}
 
 
 
		}
		catch ( Exception ex )
		{
			log.log( Level.SEVERE,
					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$
		}
		catch ( OutOfMemoryError err )
		{
			log.log( Level.SEVERE,
					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$
			throw err;
		}
	}
 
	/**
	 * @param offset
	 *            the offset of the reportlet to be rendered
	 * @throws EngineException
	 *             throws exception if there is a rendering error
	 */
	protected void doRenderReportlet( long offset ) throws OutOfMemoryError
	{
		try
		{
			if (offset != -1)
			{
				// start the render
 
				IContentEmitter emitter = createContentEmitter( );
				ReportDesignHandle reportDesign = executionContext.getDesign( );
				String format = executionContext.getOutputFormat( );
				if ( "pdf".equalsIgnoreCase( format ) || "xls".equalsIgnoreCase( format ) || "ppt".equalsIgnoreCase( format ) ) //$NON-NLS-1$
				{
					IReportExecutor executor = new ReportletReader(
							executionContext, offset );
					executor = new LocalizedReportExecutor( executionContext,
							executor );
					executionContext.setExecutor( executor );
					initializeContentEmitter( emitter, executor );
					IReportLayoutEngine layoutEngine = LayoutEngineFactory
							.createLayoutEngine( format );
					startRender( );
					layoutEngine.layout( executor, emitter );
					closeRender( );
					executor.close( );
				}
				else
				{
					ReportContentLoader loader = new ReportContentLoader(
							executionContext );
					IReportExecutor executor = new ReportExecutor(
							executionContext, reportDesign, null );
					executor = new LocalizedReportExecutor( executionContext,
							executor );
					executionContext.setExecutor( executor );
 
					initializeContentEmitter( emitter, executor );
					startRender( );
					loader.loadReportlet( offset, emitter );
					closeRender( );
					executor.close( );
				}
			}
		}
		catch ( Exception ex )
		{
			log.log( Level.SEVERE,
					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$
		}
		catch ( OutOfMemoryError err )
		{
			log.log( Level.SEVERE,
					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$
			throw err;
		}
	}	
 
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setEmitterID(java.lang.String)
	 */
	public void setEmitterID( String id )
	{
		this.emitterID = id;
	}
 
	/**
	 * @return the emitter ID to be used to render this report. Could be null,
	 *         in which case the engine will choose one emitter that matches the
	 *         requested output format.
	 */
	public String getEmitterID( )
	{
		return this.emitterID;
	}
 
	public void close( )
	{
		closeReportDocument( );
		super.close( );
	}
 
	public void render( String pageRange ) throws EngineException
	{
		setPageRange( pageRange );
		render( );
	}
 
	private List parsePageSequence( String pageRange, long totalPage )
	{
		ArrayList list = new ArrayList( );
		if ( null == pageRange
				|| "".equals( pageRange ) || pageRange.toUpperCase( ).indexOf( "ALL" ) >= 0 ) //$NON-NLS-1$ //$NON-NLS-2$
		{
			list.add( new long[]{1, totalPage} );
			return list;
		}
		String[] ps = pageRange.split( "," ); //$NON-NLS-1$
		for ( int i = 0; i < ps.length; i++ )
		{
			try
			{
				if ( ps[i].indexOf( "-" ) > 0 ) //$NON-NLS-1$
				{
					String[] psi = ps[i].split( "-" ); //$NON-NLS-1$
					if ( psi.length == 2 )
					{
						long start = Long.parseLong( psi[0].trim( ) );
						long end = Long.parseLong( psi[1].trim( ) );
						if ( end > start )
						{
							list.add( new long[]{Math.max( start, 1 ),
									Math.min( end, totalPage )} );
						}
					}
					else
					{
						log.log( Level.SEVERE,
								"error page number range: {0}", ps[i] ); //$NON-NLS-1$
					}
				}
				else
				{
					long number = Long.parseLong( ps[i].trim( ) );
					if ( number > 0 && number <= totalPage )
					{
						list.add( new long[]{number, number} );
					}
					else
					{
						log.log( Level.SEVERE,
								"error page number range: {0}", ps[i] ); //$NON-NLS-1$
					}
 
				}
			}
			catch ( NumberFormatException ex )
			{
				log.log( Level.SEVERE, "error page number rang:", ps[i] ); //$NON-NLS-1$
			}
		}
		return sort( list );
	}
 
	private List sort( List list )
	{
		for ( int i = 0; i < list.size( ); i++ )
		{
			long[] currentI = (long[]) list.get( i );
			int minIndex = i;
			long[] min = currentI;
			for ( int j = i + 1; j < list.size( ); j++ )
			{
				long[] currentJ = (long[]) list.get( j );
				if ( currentJ[0] < min[0] )
				{
					minIndex = j;
					min = currentJ;
				}
			}
			if ( minIndex != i )
			{
				// swap
				list.set( i, min );
				list.set( minIndex, currentI );
			}
		}
		long[] current = null;
		long[] last = null;
		ArrayList ret = new ArrayList( );
		for ( int i = 0; i < list.size( ); i++ )
		{
			current = (long[]) list.get( i );
			if ( last != null )
			{
				if ( current[1] <= last[1] )
					continue;
				if ( current[0] <= last[1] )
					current[0] = last[1];
					ret.add( current );
			}
			else
			{
				ret.add( current );
			}
			last = current;
		}
		return ret;
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render(org.eclipse.birt.report.engine.api.InstanceID)
	 */
	public void render(InstanceID iid) throws EngineException {
		setInstanceID( iid );
		render( );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render()
	 */
	public void render() throws EngineException {
		if ( renderOptions == null )
		{
			throw new EngineException(
					"Render options have to be specified to render a report." ); //$NON-NLS-1$
		}
		innerRender.render( );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#render()
	 */
	public void setPageNumber( long pageNumber ) throws EngineException
	{
		long totalPage = reportDoc.getPageCount( );
		if ( pageNumber <= 0 || pageNumber > totalPage )
		{
			throw new EngineException( "Can't find page hints :{0}", new Long( //$NON-NLS-1$
					pageNumber ) );
		}
		innerRender = new PageRender( pageNumber);
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setInstanceID( InstanceID iid )
	 */
	public void setInstanceID( InstanceID iid ) throws EngineException
	{
		innerRender = new ReportletRender( iid );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setPageRange( String pageRange )
	 */
	public void setPageRange( String pageRange ) throws EngineException
	{
		innerRender = new PageRangeRender( parsePageSequence( pageRange, reportDoc.getPageCount( )) );
	}
 
	/* (non-Javadoc)
	 * @see org.eclipse.birt.report.engine.api.IRenderTask#setBookmark( String bookmark )
	 */
	public void setBookmark( String bookmark ) throws EngineException
	{
		long pageNumber = reportDoc.getPageNumber( bookmark );
		if ( pageNumber <= 0 ) {
			throw new EngineException( "Can't find bookmark :{0}", bookmark ); //$NON-NLS-1$
		}
		innerRender = new PageRender( pageNumber );
	}
 
	public void setReportlet( String bookmark ) throws EngineException
	{
		innerRender = new ReportletRender( bookmark ); 
	}
 
	private interface InnerRender
	{
		void render() throws EngineException;
	}
 
	/**
	 * Renders a page with a page number. 
	 */
	private class PageRender implements InnerRender
	{
		private long pageNumber;
 
		public PageRender( long pageNumber )
		{
			this.pageNumber = pageNumber;
		}
 
		public void render( ) throws EngineException
		{
			RenderTask.this.doRender( pageNumber );
		}
	}
 
	/**
	 * Renders a range of pages. 
	 */
	private class PageRangeRender implements InnerRender
	{
		private List pageRange;
 
		public PageRangeRender( long[] arrayRange )
		{
			this.pageRange = new ArrayList();
			pageRange.add( arrayRange );
		}
 
		public PageRangeRender( List pageRange )
		{
			this.pageRange = pageRange;
		}
 
		public void render( ) throws EngineException
		{
			RenderTask.this.doRender( pageRange );
		}
	}
 
	private class ReportletRender implements InnerRender
	{
		private long offset;
 
		ReportletRender(InstanceID iid) throws EngineException
		{
			this.offset = reportDoc.getInstanceOffset( iid );
			if ( offset == -1 )
			{
				throw new EngineException(
					"Invalid instance id :" + iid ); //$NON-NLS-1$
			}
		}
 
		ReportletRender( String bookmark ) throws EngineException
		{
			this.offset = reportDoc.getBookmarkOffset( bookmark );
			if ( offset == -1 )
			{
				throw new EngineException(
					"Invalid bookmark :" + bookmark ); //$NON-NLS-1$
			}
		}
 
		public void render( ) throws EngineException
		{
			RenderTask.this.doRenderReportlet( offset );
		}
	}
 
	public void setInstanceID( String iid ) throws EngineException
	{
		setInstanceID( InstanceID.parse( iid ));
	}
}
On notera notamment dans la méthode doRender qu'il accepte en plus du pdf : le xls et le ppt.
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h41   #11
Membre Expert
 
Avatar de moritan
 
Homme
Développeur Java
Inscription : juin 2005
Messages : 657
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 32
Localisation : France, Manche (Basse Normandie)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juin 2005
Messages : 657
Points : 1 050
Points : 1 050
Voici la solution que j'ai utilisé pour avoir un format excel.

Je passe par un fichier iqy(fichier de 3 lignes), c'est fait pour çà.
Code :
1
2
3
4
 
WEB
1
http://monserveur/run?report=truc&__format=html
Car en fait dans le fichier IQY, il suffit de lui mettre une URL (celle du format html). Et excel le digère très bien.
moritan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h47   #12
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
En fait, je ne parle pas du BIRT Viewer mais bien du Birt Engine.
Bref du Java quoi, je n'arrive pas à générer un fichier Excel en utilisant l'API.

Avec le run + format ça marche très bien Mais là n'est pas la question
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 10h58   #13
Membre Expert
 
Avatar de moritan
 
Homme
Développeur Java
Inscription : juin 2005
Messages : 657
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 32
Localisation : France, Manche (Basse Normandie)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juin 2005
Messages : 657
Points : 1 050
Points : 1 050
Citation:
Envoyé par tiboudchou
En fait, je ne parle pas du BIRT Viewer mais bien du Birt Engine.
Bref du Java quoi, je n'arrive pas à générer un fichier Excel en utilisant l'API.

Avec le run + format ça marche très bien Mais là n'est pas la question

OK je n'avais pas compris que tu publiais à partir d'un client lourd.
moritan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 11h00   #14
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Tu peux publier à partir d'un client léger sans passer par le viewer...
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 11h01   #15
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
Non non le client est léger
En fait c'est une application J2EE mais les possibilités du BIRT Viewer sont trop limitées, alors pour publier les rapports, je le fais en Java + saisie de paramètres via JSP pour le client. Bref mon code Java est donc sur le serveur

EDIT : ahh, BiM m'a devancé :p
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 11h12   #16
Membre Expert
 
Avatar de moritan
 
Homme
Développeur Java
Inscription : juin 2005
Messages : 657
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 32
Localisation : France, Manche (Basse Normandie)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juin 2005
Messages : 657
Points : 1 050
Points : 1 050
Citation:
Envoyé par tiboudchou
Non non le client est léger
En fait c'est une application J2EE mais les possibilités du BIRT Viewer sont trop limitées, alors pour publier les rapports, je le fais en Java + saisie de paramètres via JSP pour le client. Bref mon code Java est donc sur le serveur

EDIT : ahh, BiM m'a devancé :p
Donc tu as plus ou moins la même archi que moi.
Effectivement le viewer standard est limité et vaux mieux le refaire mais ce n'était qu'un exemple.

Quesqu'y t'enpèche dans ta jsp de rajouter un format XLS, qui en fait renvoie vers un fichier iqy généré à la volé qui contient l'url de consultation du rapport au format HTML ?

Après c'est juste une solution alternative pour ne pas rajouter d'emitter.

Comme dirais un grand philosofe poilu : C'est vous qui voyait...
moritan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 11h14   #17
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Je fais la même chose alors forcément...
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 11h18   #18
Membre Expert
 
Avatar de moritan
 
Homme
Développeur Java
Inscription : juin 2005
Messages : 657
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 32
Localisation : France, Manche (Basse Normandie)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juin 2005
Messages : 657
Points : 1 050
Points : 1 050
Citation:
Envoyé par BiM
Je fais la même chose alors forcément...
Je crois qu'on fait tous la même chose.

Enfin plus maintenant, j'ai livré donc je suis parti sur autre chose.
moritan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 16h32   #19
Membre du Club
 
Développeur Java
Inscription : juillet 2004
Messages : 204
Détails du profil
Informations personnelles :
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juillet 2004
Messages : 204
Points : 69
Points : 69
J'ai appliqué la solution du petit fichier intermédiaire temporairement, merci à toi
Cela dit, le fichier Excel généré est très laid, le bleu pastel est devenu bleu turquoise fluo et des cases sont décalées ... une idée ?
tiboudchou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2006, 16h43   #20
Membre Expert
 
Avatar de moritan
 
Homme
Développeur Java
Inscription : juin 2005
Messages : 657
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 32
Localisation : France, Manche (Basse Normandie)

Informations professionnelles :
Activité : Développeur Java

Informations forums :
Inscription : juin 2005
Messages : 657
Points : 1 050
Points : 1 050
Citation:
Envoyé par tiboudchou
J'ai appliqué la solution du petit fichier intermédiaire temporairement, merci à toi
Cela dit, le fichier Excel généré est très laid, le bleu pastel est devenu bleu turquoise fluo et des cases sont décalées ... une idée ?
Moi j'avais retenu cette solution car je trouvé le fichier excel plus propre...
Pour les couleurs, ça doit venir de la palette de couleur excel, ç voir si elle est modifiable. ou alors voir comment sont défini les couleurs dans le rapport pour voir si elle sont en code hexa ou pas, le code pour blue est peut-être différent entre IE et Excel.

Pour les cases c'est bizarre, serait-ce des cases de tableau vides masquer dans IE?
Car IE met les cellules vide à 0%, mais Excel les mets à la taille par défaut donc visible.


PS: un avantage de cette méthode c'est qu'on peut rafraichier le rapport en direct dans Excel avec F5.
moritan est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 00h14.


 
 
 
 
Partenaires

Hébergement Web