how to get .jasper and .bak and also view direct excel in iReport 2.0.2 - jasper-reports

I have problems to view report. first, when I try to click view button on the excel button in 'build'. it not view out the report but it is just generate excel files in a folder only. Secondly, Can I get the file .Jasper and .bak after I view the report.
The main problem is when i want to view direct my report for excel. The error show:-
 Exporting XLS to file (using POI)... .\senarai_cpp_4(1)_tnsparthis_pembaharuanPenangguhan.xls.
Error exporting print... Sheet name cannot be blank, greater than 31 chars, or contain any of /\*?[]
Can't find the translation for key = iReportCompiler.errorExportingPrint: using default (Error exporting print... {0} )  java.lang.IllegalArgumentException: Sheet name cannot be blank, greater than 31 chars, or contain any of /\*?[]      at org.apache.poi.hssf.record.BoundSheetRecord.setSheetname(BoundSheetRecord.java:162)      at org.apache.poi.hssf.model.Workbook.setSheetName(Workbook.java:464)      at org.apache.poi.hssf.usermodel.HSSFWorkbook.createSheet(HSSFWorkbook.java:540)      at net.sf.jasperreports.engine.export.JRXlsExporter.createSheet(JRXlsExporter.java:147)      at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:393)      at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:221)      at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:1329)      at java.lang.Thread.run(Unknown Source) 
Export running time: 1,212

The old version of iReport uses an outdated version of POI. The library doesn't have the ability to truncate sheet names for excel. The solution is to rename you report (jrxml) to have a short filename.
You can change the location of the backup file by going into Tools -> Options.

Related

How can I generate Jasper Report into XLS Format in Adempiere precisely?

I have set up Jasper Report to be generated into XLS format.
When I click print button, it will show like this :
Then, when I choose "Excel", download pop up will appear and my .xls format will be downloaded.
Unfortunately, when I open the file, it doesn't generated precisely, there are columns that doesn't fit correctly, like this :
How can I generate JasperReports's report into XLS with correct format and got all my data shown correctly?
I have experienced the same issue while creating Jasper Reports and exporting to Excel. The main reason for this is the column overlapping while creating report. If you take a closer look you will notice that any column of Jasper Report which gets overlapped turns into green from blue. If you completely remove overlapping in columns, then Excel format will come out without any issues.
P.S ..Coming from Personal Experience!!!
This just happened to me.
How I solved it was selecting every field in the Jasper Report and setting the following properties:
isStretchWithOverflow="true"
isRemoveLineWhenBlank="true"
Hope it works

Can I use a Microsoft Word file as a report template for JasperReports?

I have several model contracts in Microsoft Word files with as many as 20 pages per file). I would like to use Jasper Reports to fill out these contracts.
I tried importing the doc file into iReport, but that is not working.
Is there a way to convert a Microsoft Word file to a JasperReport template?
Try to convert the doc into excel and than use the excel as datasource in ireport.
Edit: Based on OP's comment.
You can not use a Microsoft word file as a JasperReport template. You will need to create a JRXML file for JasperReports. It is possible to use rtf or html as source for text fields but the final formating of such field is rather pure.
Your other option is to not user JasperReports and manipulate the Microsoft Word files directly using Apache Poi.

How to most effectively automate repetitive Excel task?

I want to automate Excel using Perl to do the following task(s):
For a list of Excel .xls files, do the following:
Open the file
Set Format to CSV
Save the file under the original filename and directory, but replace the extension "xls" with "csv"
Close the file
End
I found how to open files, even how to save them. I did not find how to change the fileformat/save as a different format. There shall be no user dialogs popping up, it should be fully automated. The Excel file list I can generate myself, a parameterized "find" or maybe "dir" should suffice.
If you are using Excel automation a great help is Excel itself. Use the VBA environment (Alt+F11) to get help for the Excel objects you want to use.
The objectbrowser (F2) is very valuable.
Workbook.SaveAs([Filename], [FileFormat], [Password], [WriteResPassword], [ReadOnlyRecommended], [CreateBackup], [AccessMode As XlSaveAsAccessMode = xlNoChange], [ConflictResolution], [AddToMru], [TextCodepage], [TextVisualLayout], [Local])
Searching for CSV in the object browser will show Excel constants with their values, since you probably cannot use these Excel constants in Perl.
See Spreadsheet::ParseExcel and xls2csv, they will help you.

How to change PowerPoint chart data with .NET?

I have a PowerPoint template that contains one slide and on that slide is a chart. I'd like to be able to manipulate that chart's data using .NET.
So far I have code that...
unzips the Powerpoint file.
unzips the embedded excel file (ppt\embeddings\Microsoft_Office_Excel_Worksheet1.xlsx)
It successfully manipulates the data in the excel sheet and zips it back up.
Opens and manipulates ppt\charts\chart1.xml
Powerpoint is then zipped up and delivered to the user
The result of this is a PowerPoint file that shows a blank chart. But when I click on the chart and go to edit data it updates the data and shows the correct chart.
I believe my problem is with the chart1.xml that I am generating. I have compared my generated version with a version created by PowerPoint and they are almost identical. The only differences are in the values for <c:crossAx/> and <c:axId/>.
There are also some rounding differences in the data. But I do not feel like that would result in a blank chart.
Is there another file that I need to edit? Does anyone have any ideas as to what else I should try to get this working?
It's likely a combination the axID value and the rounding issues. The Axis ID, likely, is asking for an integer value and you may be supplying a single/double. So the cached data in chart1.xml doesn't know how to display.
Try your same manipulation that you've been doing, but instead of opening the result in PowerPoint, change the .pptx extention to .zip, unzip and then manually fix the rounding issues to match the original rounding. Then zip back up, change extension back to .pptx and open in PowerPoint. If this fixes the issue of display, you can confirm it is the rounding issue.
Alternatively, and along the same lines. Open your resulting PPTX in PowerPoint as you have been doing, and once you've right-clicked and rehydrated the chart, save as a different file name and compare that with your automated result.

Is it possible to show the contents of a text file in Crystal Reports

I have a crystal report which contains a list of absolutely referenced text files. There is one text file referenced in each body line.
e.g.
line1 c:\file1.txt
line2 c:\file2.txt
Is there any way to display the contents of these files in Crystal?
i.e. I would like each crystal body line to show the text from the referenced text file.
I'm using Crystal reports 11 with a non-standard database connector (dataflex).
You would need to set up a file dsn (in XP it's under Control Panel/Administrative Tools/Datasources (ODBC)) and then use the file dsn (Microsoft Text Driver) for the datasource as an ODBC(RDO) connection.
I set this test scenario up on mine like the following:
**File 1**
column1
1row1
1row2
1row3
**File 2**
column1
2row1
2row2
2row3
I set up the file dsn to point to the c drive and in the datasource screen I added file1.txt and file2.txt to the selected tables. Then the easiest thing to do is clear the links of the tables so that it pulls every row. It will warn you that there are multiple starting points. I don't generally recomend this, but it will work in this case and since it's not reporting off a database it probably isn't the end of the world. If you disregard the starting point message then add the fields to the report, when you run it you should get the following output:
1row1 2row1
1row1 2row2
1row1 2row3
1row2 2row1
1row2 2row2
1row2 2row3
1row3 2row1
1row3 2row2
1row3 2row3
From this you can change your grouping to get the output that you need.
You can also use this same connect against subreports instead of doing this linking where you have the main report pull the info from file1.txt and then put a subreport in the report footer that pulls from file2.txt. This option won't have the text collated, but you'd still have it in the same report.
Hope this helps some.
It's easier than you think. I just set up one myself before I wrote this to make sure I was giving you the right steps. Using CR version XI and a .txt file, I followed these steps:
For each text file you want to import, make a subsection in your report (i.e. DetailsA, DetailsB, etc.). If your list of text files is constantly changing (and I don't think it is, based on your description), you'll need another method.
Make sure your text file is comma delimited and the first row contains field names. If these text files are actually text (i.e. not tables), then just put a dummy variable name in the first row so Crystal will see the text as a table of data with just 1 row.
For each text file you want to display, create a new Subreport (Insert->Subreport)
In the database selection menu, go to "Create New Connection"->"Access/Excel (DAO)"
Under 'database type', you'll see a 'text' option at the bottom of the screen.
Choose your file.
Relax! (I'm in a good mood this morning, don't know why)
I guess if you have a function that takes a file name as an argument and returns the contents of that file - you could use that function in a Crystal Report formula.
I am not familiar with the current CR, it has been years since I last used it (I last used version 8). In the versions I did use, such a function was not built in. What you would have to do back then, was to create a UFL (user function library) containing the functions you needed. If I remember correctly, you had to do this using COM.
In this day and age, I guess you can extend CR using some other mechanism, perhaps writing .NET code?
I suggest you search the CR documentation for the term UFL.
Another suggestion, then:
Create a new table FILECONTENTS (filename varchar primary key, contents blob)
Create a script that on a schedule populates this table with the filenames and contents of all the files (assuming that there is a finite number of files, and that you have a way of knowing about them)
Modify the report datasource query to join it with the FILECONTENTS table, and add the contents field to the report.
You could setup a file dsn. But this is geared toward tabular file data, not text.
How big are these text files? You want to display the entire contents of each file?
There is probably no easy way to dynamically read in a file from within crystal. You will most likely have to push a dataset to the report which contains the file contents.