1 28 package net.sf.jasperreports.engine; 29 30 import java.io.File ; 31 import java.io.InputStream ; 32 import java.io.OutputStream ; 33 import java.sql.Connection ; 34 import java.util.Map ; 35 36 import net.sf.jasperreports.engine.util.JRLoader; 37 38 39 45 public class JasperRunManager 46 { 47 48 49 53 public static String runReportToPdfFile( 54 String sourceFileName, 55 Map parameters, 56 Connection conn 57 ) throws JRException 58 { 59 File sourceFile = new File (sourceFileName); 60 61 62 JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); 63 64 65 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); 66 67 68 File destFile = new File (sourceFile.getParent(), jasperPrint.getName() + ".pdf"); 69 String destFileName = destFile.toString(); 70 71 JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); 72 73 return destFileName; 74 } 75 76 77 87 public static String runReportToPdfFile( 88 String sourceFileName, 89 Map parameters 90 ) throws JRException 91 { 92 File sourceFile = new File (sourceFileName); 93 94 95 JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); 96 97 98 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters); 99 100 101 File destFile = new File (sourceFile.getParent(), jasperPrint.getName() + ".pdf"); 102 String destFileName = destFile.toString(); 103 104 JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); 105 106 return destFileName; 107 } 108 109 110 114 public static void runReportToPdfFile( 115 String sourceFileName, 116 String destFileName, 117 Map parameters, 118 Connection conn 119 ) throws JRException 120 { 121 122 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, conn); 123 124 JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); 125 } 126 127 128 138 public static void runReportToPdfFile( 139 String sourceFileName, 140 String destFileName, 141 Map parameters 142 ) throws JRException 143 { 144 145 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters); 146 147 JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); 148 } 149 150 151 155 public static void runReportToPdfStream( 156 InputStream inputStream, 157 OutputStream outputStream, 158 Map parameters, 159 Connection conn 160 ) throws JRException 161 { 162 163 JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters, conn); 164 165 JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream); 166 } 167 168 169 179 public static void runReportToPdfStream( 180 InputStream inputStream, 181 OutputStream outputStream, 182 Map parameters 183 ) throws JRException 184 { 185 186 JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters); 187 188 JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream); 189 } 190 191 192 196 public static byte[] runReportToPdf( 197 String sourceFileName, 198 Map parameters, 199 Connection conn 200 ) throws JRException 201 { 202 203 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, conn); 204 205 return JasperExportManager.exportReportToPdf(jasperPrint); 206 } 207 208 209 219 public static byte[] runReportToPdf( 220 String sourceFileName, 221 Map parameters 222 ) throws JRException 223 { 224 225 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters); 226 227 return JasperExportManager.exportReportToPdf(jasperPrint); 228 } 229 230 231 235 public static byte[] runReportToPdf( 236 InputStream inputStream, 237 Map parameters, 238 Connection conn 239 ) throws JRException 240 { 241 242 JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters, conn); 243 244 return JasperExportManager.exportReportToPdf(jasperPrint); 245 } 246 247 248 258 public static byte[] runReportToPdf( 259 InputStream inputStream, 260 Map parameters 261 ) throws JRException 262 { 263 264 JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters); 265 266 return JasperExportManager.exportReportToPdf(jasperPrint); 267 } 268 269 270 274 public static byte[] runReportToPdf( 275 JasperReport jasperReport, 276 Map parameters, 277 Connection conn 278 ) throws JRException 279 { 280 281 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); 282 283 return JasperExportManager.exportReportToPdf(jasperPrint); 284 } 285 286 287 297 public static byte[] runReportToPdf( 298 JasperReport jasperReport, 299 Map parameters 300 ) throws JRException 301 { 302 303 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters); 304 305 return JasperExportManager.exportReportToPdf(jasperPrint); 306 } 307 308 309 313 public static String runReportToPdfFile( 314 String sourceFileName, 315 Map parameters, 316 JRDataSource jrDataSource 317 ) throws JRException 318 { 319 File sourceFile = new File (sourceFileName); 320 321 322 JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); 323 324 325 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource); 326 327 328 File destFile = new File (sourceFile.getParent(), jasperPrint.getName() + ".pdf"); 329 String destFileName = destFile.toString(); 330 331 JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); 332 333 return destFileName; 334 } 335 336 337 341 public static void runReportToPdfFile( 342 String sourceFileName, 343 String destFileName, 344 Map parameters, 345 JRDataSource jrDataSource 346 ) throws JRException 347 { 348 349 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, jrDataSource); 350 351 352 JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); 353 } 354 355 356 360 public static void runReportToPdfStream( 361 InputStream inputStream, 362 OutputStream outputStream, 363 Map parameters, 364 JRDataSource jrDataSource 365 ) throws JRException 366 { 367 368 JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters, jrDataSource); 369 370 JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream); 371 } 372 373 374 378 public static byte[] runReportToPdf( 379 String sourceFileName, 380 Map parameters, 381 JRDataSource jrDataSource 382 ) throws JRException 383 { 384 385 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, jrDataSource); 386 387 return JasperExportManager.exportReportToPdf(jasperPrint); 388 } 389 390 391 395 public static byte[] runReportToPdf( 396 InputStream inputStream, 397 Map parameters, 398 JRDataSource jrDataSource 399 ) throws JRException 400 { 401 402 JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parameters, jrDataSource); 403 404 return JasperExportManager.exportReportToPdf(jasperPrint); 405 } 406 407 408 412 public static byte[] runReportToPdf( 413 JasperReport jasperReport, 414 Map parameters, 415 JRDataSource jrDataSource 416 ) throws JRException 417 { 418 419 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource); 420 421 return JasperExportManager.exportReportToPdf(jasperPrint); 422 } 423 424 425 429 public static String runReportToHtmlFile( 430 String sourceFileName, 431 Map parameters, 432 Connection conn 433 ) throws JRException 434 { 435 File sourceFile = new File (sourceFileName); 436 437 438 JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); 439 440 441 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); 442 443 444 File destFile = new File (sourceFile.getParent(), jasperPrint.getName() + ".html"); 445 String destFileName = destFile.toString(); 446 447 JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); 448 449 return destFileName; 450 } 451 452 453 463 public static String runReportToHtmlFile( 464 String sourceFileName, 465 Map parameters 466 ) throws JRException 467 { 468 File sourceFile = new File (sourceFileName); 469 470 471 JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); 472 473 474 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters); 475 476 477 File destFile = new File (sourceFile.getParent(), jasperPrint.getName() + ".html"); 478 String destFileName = destFile.toString(); 479 480 JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); 481 482 return destFileName; 483 } 484 485 486 490 public static void runReportToHtmlFile( 491 String sourceFileName, 492 String destFileName, 493 Map parameters, 494 Connection conn 495 ) throws JRException 496 { 497 498 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, conn); 499 500 JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); 501 } 502 503 504 514 public static void runReportToHtmlFile( 515 String sourceFileName, 516 String destFileName, 517 Map parameters 518 ) throws JRException 519 { 520 521 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters); 522 523 JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); 524 } 525 526 527 531 public static String runReportToHtmlFile( 532 String sourceFileName, 533 Map parameters, 534 JRDataSource jrDataSource 535 ) throws JRException 536 { 537 File sourceFile = new File (sourceFileName); 538 539 540 JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); 541 542 543 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource); 544 545 546 File destFile = new File (sourceFile.getParent(), jasperPrint.getName() + ".html"); 547 String destFileName = destFile.toString(); 548 549 JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); 550 551 return destFileName; 552 } 553 554 555 559 public static void runReportToHtmlFile( 560 String sourceFileName, 561 String destFileName, 562 Map parameters, 563 JRDataSource jrDataSource 564 ) throws JRException 565 { 566 567 JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, jrDataSource); 568 569 570 JasperExportManager.exportReportToHtmlFile(jasperPrint, destFileName); 571 } 572 573 574 } 575 | Popular Tags |